From Test-Scratch-Wiki
(Redirected from Eng:Letter () of ())
Letter () of () | |
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 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
Variations
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) end
See Also
— the version for lists
References
() + ()
• () - () • () * () • () / () • Pick Random () to () • () < () • () = () • () > () • () and () • () or () • Not () • Join ()() • Letter () of () • Length of () • () Mod () • Round () • () of ()More blocks... |