zacharyn35 zacharyn35 loading

-stxllxr wrote:

You can use lists to do this, have a list with all the numbers you want to convert into words, and vice versa.
say you want the word “hello” to convert into 1, and the word “goodbye” to convert into 2, you can have a list like this:
list:
item 1: hello
item 2: goodbye

then you can use these 2 blocks to convert back and forth:
(item ( v) of [list v] :: list)
(item # of () in [list v] ::list)
And here is how you can convert them back and forth. This is basically a primitive version of decoding and encoding, I would recommend searching up or researching it.
define convert thing (t) into number
set [thing v] to (item # of (t) in [list v] ::list)

define deconvert number (n) into thing
set [thing v] to (item (n) of [list v])
Using the list shown above, and the blocks above, you can convert a word using items in a list, and convert them back.

Edit:
Using these blocks like this:
convert thing [goodbye] into number ::custom
would convert goodbye into “2”, since goodbye is item 2 of the list, and deconverting it would use the item number to then again get the original item, “goodbye”.
Thanks! Also do you have a code so that it changes it to numbers based on the letter. (Ex. Hi would be 9,10)