From Test-Scratch-Wiki
(Redirected from Eng:Item () of ())
Item () of () | |
Category | List |
Type | Reporter |
Introduced in | 1.3 |
The Item () of () block is a List block and a Reporter block. The block reports the value of the specified entry in a specified list.
Example Uses
When a certain item in a list must be recalled, this block can be used.
Some common uses for the Item () of () block:
- Reporting an object
ask [Which item would you like on our menu today?] and wait change [cost v] by (item (answer) of [food costs v]) say (join (join [We'll be making your ](item (answer) of [food names v]))[ in a minute.])
- Recalling part of a record
ask [What highscore would you like to know?] and wait say (join (join (join [Highscore ](answer))[ is: ])(item (answer) of [highscores v]))
- Comparing different items
if <(item (1 v) of [collection v]) = (item (1 v) of [pack v])> then say [I already have this item in my pack.] for (3) secs
Workaround
- Main article: List of Block Workarounds
The text options of this block can be worked around by dropping Reporter blocks into the dropdown-value menu.
Random
(item (random v) of [list v])
chooses a random item in the list. Thus, it can be replicated with the following code:
(item (pick random (1) to (length of [list v])) of [list v])
This also gives the ability to use lists as a workaround for the Pick Random () to () block.
Last
"Last" gives the last item of the selected list.
(item (last v) of [list v]
Its replica is:
(item (length of [list v]) of [list v])//only if length of list > 0
See Also
— the version for strings
Variables Blocks | |
List Blocks |