In Scratch, how can you split a string into a list of characters?

My son is interested in the ROT-13 code. I would like to help him write a program in MIT Scratch that can take a string as input and return ROT-13 encoded text as output. To do this, the program will need to take a string, select all the characters, change the characters in accordance with the ROT-13 type, and again collect them into a string.

I understand that Scratch is not really designed to handle strings, but it is a programming environment that my son understands. Is such string manipulation possible in Scratch? If so, how to do it? To begin with, how would you divide a string into the equivalent of an array of characters?

+4
source share
2 answers

- .

set [i v] to (0)
repeat (length of (originalString))
  change [i v] by (1)
  add (letter (i) of (originalString)) to [characters v]
end

( )

characters .

+6

( )...

delete (all v) of [Output v]
repeat (length of (originalString))
  add (letter((length of [Output v]) + (1)) of (originalString)) to [Output v]
end

+2

All Articles