Discuss Scratch

gaz-boy1
Scratcher
11 posts

Converting text into Binary

Hi, so i'm trying to convert a list composed of text into binary… i know im not very clear but if anyone could help that'd be awesome.
basically what i want to do is have the user input text then it will add the text to a list and convert that item of the list to binary…
also id like to be able to change it back to text….
theonlygusti
Scratcher
1000+ posts

Converting text into Binary

Why binary?
lederniersamourai
Scratcher
500+ posts

Converting text into Binary

1) put all characters (abcABC123+=-…) in a string variable
set [chars v] to [ABCabc123?+=-... ]
2) to code any character into just do the following:
set [index v] to [1]
repeat until <(the_character) = (letter (index) of [chars])>
change [index] by (1)
end
Then you can use the number inside the variable index as the decimal (or binary) code of the letter. If you want to have a fixed length for the code you can add 1000 for instance. In that case, All codes will be 4 digits numbers.

You can pack all those 4-digits in a big string. You can extract those code by extracting tje first 4 characters, then the next 4 ones, then …

When you want to decode the code into the original letter, you just have to subtract 1000, then you use this to get back the character:
(letter (code) of [chars])
theonlygusti
Scratcher
1000+ posts

Converting text into Binary

lederniersamourai wrote:

1) put all characters (abcABC123+=-…) in a string variable
set [chars v] to [ABCabc123?+=-... ]
2) to code any character into just do the following:
set [index v] to [1]
repeat until <(the_character) = (letter (index) of [chars])>
change [index] by (1)
end
Then you can use the number inside the variable index as the decimal (or binary) code of the letter. If you want to have a fixed length for the code you can add 1000 for instance. In that case, All codes will be 4 digits numbers.

You can pack all those 4-digits in a big string. You can extract those code by extracting tje first 4 characters, then the next 4 ones, then …

When you want to decode the code into the original letter, you just have to subtract 1000, then you use this to get back the character:
(letter (code) of [chars])
But that would require a binary->number->binary conversion, so I ask again, why binary?
gaz-boy1
Scratcher
11 posts

Converting text into Binary

theonlygusti wrote:

lederniersamourai wrote:

1) put all characters (abcABC123+=-…) in a string variable
set [chars v] to [ABCabc123?+=-... ]
2) to code any character into just do the following:
set [index v] to [1]
repeat until <(the_character) = (letter (index) of [chars])>
change [index] by (1)
end
Then you can use the number inside the variable index as the decimal (or binary) code of the letter. If you want to have a fixed length for the code you can add 1000 for instance. In that case, All codes will be 4 digits numbers.

You can pack all those 4-digits in a big string. You can extract those code by extracting tje first 4 characters, then the next 4 ones, then …

When you want to decode the code into the original letter, you just have to subtract 1000, then you use this to get back the character:
(letter (code) of [chars])
But that would require a binary->number->binary conversion, so I ask again, why binary?
thanks for your input guys, im not sure i fully understand yet… but its for this project im working on http://scratch.mit.edu/projects/27880434/
gaz-boy1
Scratcher
11 posts

Converting text into Binary

*its because we dont have cloud data lists yet, so im converting each message into binary then storing it on a cloud variable then when someone runes the program it changes it back into text. or copy's it into the global chat list. whichever works.
gaz-boy1
Scratcher
11 posts

Converting text into Binary

so yeah i just tried that and it crashed my web browser… http://scratch.mit.edu/projects/27880434/#editor
so what exactly is it doing?
Tropic
Scratcher
1000+ posts

Converting text into Binary

gaz-boy1 wrote:

*its because we dont have cloud data lists yet, so im converting each message into binary then storing it on a cloud variable then when someone runes the program it changes it back into text. or copy's it into the global chat list. whichever works.

Binary means only 1's and 0's. Cloud data accepts numbers 0-9, not only 0's and 1's. Therefore, binary is not required

Just convert it into numbers instead of binary
MegaApuTurkUltra
Scratcher
1000+ posts

Converting text into Binary

Tropic wrote:

gaz-boy1 wrote:

*its because we dont have cloud data lists yet, so im converting each message into binary then storing it on a cloud variable then when someone runes the program it changes it back into text. or copy's it into the global chat list. whichever works.

Binary means only 1's and 0's. Cloud data accepts numbers 0-9, not only 0's and 1's. Therefore, binary is not required

Just convert it into numbers instead of binary
I would like to point out that numbers are already stored as binary in computer memory. So converting to numbers is actually converting to binary
Tropic
Scratcher
1000+ posts

Converting text into Binary

MegaApuTurkUltra wrote:

Tropic wrote:

gaz-boy1 wrote:

*its because we dont have cloud data lists yet, so im converting each message into binary then storing it on a cloud variable then when someone runes the program it changes it back into text. or copy's it into the global chat list. whichever works.

Binary means only 1's and 0's. Cloud data accepts numbers 0-9, not only 0's and 1's. Therefore, binary is not required

Just convert it into numbers instead of binary
I would like to point out that numbers are already stored as binary in computer memory. So converting to numbers is actually converting to binary

Yeah, well, I know that computers are using binary, but I just meant that converting it to binary yourself isn't necessary if the computer converts it to binary anyway
gaz-boy1
Scratcher
11 posts

Converting text into Binary

Tropic wrote:

MegaApuTurkUltra wrote:

Tropic wrote:

gaz-boy1 wrote:

*its because we dont have cloud data lists yet, so im converting each message into binary then storing it on a cloud variable then when someone runes the program it changes it back into text. or copy's it into the global chat list. whichever works.

Binary means only 1's and 0's. Cloud data accepts numbers 0-9, not only 0's and 1's. Therefore, binary is not required

Just convert it into numbers instead of binary
I would like to point out that numbers are already stored as binary in computer memory. So converting to numbers is actually converting to binary

Yeah, well, I know that computers are using binary, but I just meant that converting it to binary yourself isn't necessary if the computer converts it to binary anyway

so maybe i should just ask for help on my project then, storing the text in a cloud variable somehow.
Tropic
Scratcher
1000+ posts

Converting text into Binary

gaz-boy1 wrote:

Tropic wrote:

MegaApuTurkUltra wrote:

Tropic wrote:

gaz-boy1 wrote:

*its because we dont have cloud data lists yet, so im converting each message into binary then storing it on a cloud variable then when someone runes the program it changes it back into text. or copy's it into the global chat list. whichever works.

Binary means only 1's and 0's. Cloud data accepts numbers 0-9, not only 0's and 1's. Therefore, binary is not required

Just convert it into numbers instead of binary
I would like to point out that numbers are already stored as binary in computer memory. So converting to numbers is actually converting to binary

Yeah, well, I know that computers are using binary, but I just meant that converting it to binary yourself isn't necessary if the computer converts it to binary anyway

so maybe i should just ask for help on my project then, storing the text in a cloud variable somehow.

Maybe you can just use someone elses encoder and decoder I think @Lirex have made one, I have made one and lots of other Scratchers have made encoders & decoders Just give credit to them.

You can also try to make an encoder & decoder yourself, but it might be hard. And you might need to use a block that runs without screen refresh to make it go faster too.
StrawberryCoffee
Scratcher
25 posts

Converting text into Binary

gaz-boy1 wrote:

Hi, so i'm trying to convert a list composed of text into binary… i know im not very clear but if anyone could help that'd be awesome.
basically what i want to do is have the user input text then it will add the text to a list and convert that item of the list to binary…
also id like to be able to change it back to text….

Hmm, I kinda forgot how to write binary. But I bet if you tell me what you would like I can convert it for you.
- StrawberryCoffee

Powered by DjangoBB