From Test-Scratch-Wiki

Letter () of ()
2.0 Letter () of ().png
Category Operators
Type Reporter
Introduced in 1.4

The Letter () of () block is an Operators block and a Reporter block. The block reports the specified character of the given text. Even though the block says "letter", it will report all characters, including letters, numbers, symbols, and even spaces.

Example Uses

If a value must be read out from the middle of a text, this block will do the job.

Some common uses for the Letter () of () block:

  • In conjunction with the answer block to find something out about the answer
if <(letter (1) of (answer)) = [z]> then
say [That's my favorite letter too!] for (3) secs
say [Interesting.] for (2) secs
  • To find a number in the middle of a string of text
if <[numbers v] contains (letter (n) of (answer))> then
say [Number]
say [Letter/punctuation]
  • To tell whether a certain letter in a string equals a certain value
if <(letter (testing) of (answer)) = [z]> then
stop [this script v]


Some Scratch Modifications have a block that lets users choose how many characters in a string to report. This is also wanted for Scratch.[1] It would be like this: (letters () through () of [])//category=operators

However, it can be replicated with the following code:

set [report v] to []
set [count v] to (first letter)
repeat until <(count) = ((last letter) + (1))>
set [report v] to (join (report) (letter (count) of (text)))
change [count v] by (1)

See Also

— the version for lists


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