Letter () of () (block)
(Redirected from Letter () of ())
|Letter () of ()|
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. The block is also useful to write the time or show scores.
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 else say [Interesting.] for (2) secs end
- To find a number in the middle of a string of text
if <[numbers v] contains (letter (n) of (answer))> then say [Number] else say [Letter/punctuation] end
- To tell whether a certain letter in a string equals a certain value
if <(letter (testing) of (answer)) = [z]> then stop [this script v] end
Some Scratch Modifications have a block that lets users choose how many characters in a string to report. This is also wanted for Scratch. It would be like this:
(letters () through () of ::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) end