(☁ var) This article or section uses Cloud Data. Users who are New Scratchers or are using the Offline Editor cannot make projects using Cloud Data or use it in other users' projects. To use Cloud Data, the Scratcher status is needed and the Online Editor has to be used.
DocumentInQuestion.png It has been suggested that this page's contents be merged with the page Encoding and Decoding Cloud Data. You can discuss this on the page's talk page. (November 2015)
Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (July 2021)
DocumentInQuestion.png This page or section is in question as to whether it is useful or not. You can discuss whether you think it should be deleted or not on its talk page. (December 2023)
Reason: Near duplicate of Encoding and Decoding Cloud Data

As of Scratch 2.0, users can create Cloud Variables. Cloud variables are special variables stored in servers. These can only store numbers. Obviously, there is a limitation to this, and many users have wanted cloud strings and lists and suggested them multiple times in the Suggestions forum.[1]

There is a workaround for making cloud lists that work, and many users have created "engines" for them for other users to use. This tutorial will describe how to build and use a cloud list. This tutorial should explain how to create and maintain a cloud list.

Encoding and Decoding

To store strings in a cloud list, strings will need to be encoded and decoded into number format. This tutorial will show how to create one such encoder and decoder. This will enable basic strings to be stored into a compact number format. Start by making a Custom Block...

define encode (string1)

and create an iterator, which is a special name for a variable that loops through data. Another variable will be needed for the output (the encoded numbers that the encoder spits out)

set [i_encode v] to (1)
set [output v] to ()

Connect this block to the encoding definition. The iterator will need to spin through the string being encoded, so add a repeat C-block and tell it to repeat the length of the string. Here's the full code so far...

define encode (string1)
set [i_encode v] to (1)
repeat (length of (string1)) // loops through the string
change [i_encode v] by (1)
end

This block is halfway done — there just needs to be a few extra things. Create two lists with all the letters that can be encoded — for example, a list would be the alphabet and punctuation, each character on a separate item in the list. There should be 99 or fewer characters in this list.

Next, a mini-loop needs to be added inside of the first loop. This will find the correct two-letter number to add to the final output.

Here is the script:

define encode(string1)
set [i_encode v] to (1)
repeat (length of (string1)) // loops through the string
set [i_findLetter v] to (1)
repeat (length of [letters v])
if <(item (i_findLetter) of [letters v]) = (letter (i_encode) of (string1))> then
if <(length of (i_findLetter)) = (1)> then
set [output v] to (join (output)(join (0)(i_findLetter))
else
set [output v] to (join (output)(i_findLetter))
end
change [i_findLetter v] by (1)
end
end
change [i_encode v] by (1)

References

Cookies help us deliver our services. By using our services, you agree to our use of cookies.