Discuss Scratch

spyninja241001
Scratcher
48 posts

how tov split answers into seprate letters

can some one tech me how to split words
CrystalStar-
Scratcher
100+ posts

how tov split answers into seprate letters

If you mean splitting an answer into words, see this wiki article.

http://wiki.scratch.mit.edu/wiki/Separating_a_String_Into_Words

Or if you mean splitting words into letters, use something like this

set [count] to 1
delete (all) of [list]
repeat (length of [answer]) [
add (letter (count) of [answer]) to list
change count by 1
]

This will add all the letters of a string to a list. (Count is a variable.)

Last edited by CrystalStar- (Aug. 18, 2013 11:18:35)

Psiborg
Scratcher
500+ posts

how tov split answers into seprate letters

Took too long to type this :)

This will split a sentence into words and put them in a list. Not sure if that is what you want, but it should help understand about splitting words.

delete all of word_list
set word to {} - sets word variable to be blank
set i to 0 - used as a counter
repeat (length of answer) - to check each letter in answer
change i by 1 - increment counter
if < {letter (i) of answer}={ } > - checks for a space and hence the end of a word
add word to word_list - add the word to a list for processing later
set word to {} - sets variable to blank ready for next word
else
set word to (join {word} {letter (i) of answer}) - add the current letter to the current word being built
/else

It basically goes through your answer letter by letter building up words. Whenever it gets to a space it adds the word it completed to a list.

Last edited by Psiborg (Aug. 18, 2013 11:24:23)

ProdigyZeta7
Scratcher
1000+ posts

how tov split answers into seprate letters

Psiborg wrote:

delete all of word_list
set word to {} - sets word variable to be blank
set i to 0 - used as a counter
repeat (length of answer) - to check each letter in answer
change i by 1 - increment counter
if < {letter (i) of answer}={ } > - checks for a space and hence the end of a word
add word to word_list - add the word to a list for processing later
set word to {} - sets variable to blank ready for next word
else
set word to (join {word} {letter (i) of answer}) - add the current letter to the current word being built
/else
add word to word_list
Fixed. You forgot to add the last word.
Psiborg
Scratcher
500+ posts

how tov split answers into seprate letters

Thanks! I knew I should have tested it….
xooxlor
Scratcher
76 posts

how tov split answers into seprate letters

He means take every letter of a word and add it to the list. i need this for a scratch password cracker if you have a ready script please gimme a link (:
deck26
Scratcher
1000+ posts

how tov split answers into seprate letters

xooxlor wrote:

He means take every letter of a word and add it to the list. i need this for a scratch password cracker if you have a ready script please gimme a link (:
CrystalStar has already told you how to do this - use the

add (letter (5) of [your word]) to [  listname]

block to get one letter at a time. In this case we're getting the fifth letter. Put that in a loop using a variable where I've put the 5 and increase the variable each time through the loop.

Last edited by deck26 (Dec. 12, 2014 11:01:19)

tboythekid
Scratcher
1 post

how tov split answers into seprate letters

CrystalStar- wrote:

If you mean splitting an answer into words, see this wiki article.

http://wiki.scratch.mit.edu/wiki/Separating_a_String_Into_Words

Or if you mean splitting words into letters, use something like this

set [count] to 1
delete (all) of [list]
repeat (length of [answer]) [
add (letter (count) of [answer]) to list
change count by 1
]

This will add all the letters of a string to a list. (Count is a variable.)
Thanks, CrystalStar for the help.

Powered by DjangoBB