From Test-Scratch-Wiki

()
2.0 () (list).png
Category List
Type Reporter
Introduced in 1.3

The () block is a List block and a Reporter block. The block simply reports the items of its list as a string.

Whenever a list is created, a version of the block appears with the list's name on it; this results in a version of this block for every list.

This block can be displayed as a Stage monitor.

A space is put between each item when it is called. If the length of all of the items in a list is equal to 1, no space is put between the items.

Example Uses

The List reporter block is used infrequently; most information needed can be accessed by using other reporters for the list. However, here are a couple uses for this block.

Some common uses for the () block:

  • Join separate characters/words together
say (sentence::list)
  • Setting a variable to the value of this block so that a list local to a sprite can be transferred
set [unlock v] to (list::list)

Workaround

Main article: List of Block Workarounds

This block can be replicated with the following code:

set [count v] to [0]
set [all are 1 v] to [true]
repeat until <<(all are 1) = [false]> or <(count) > (length of [list v])>>
change [count v] by (1)
if <(length of (item (count) of [list v])) > [1]> then
set [all are 1 v] to [false]
end
end
if <(all are 1) = [true]> then
set [report v] to []
set [count v] to [0]
repeat (length of [list v])
change [count v] by (1)
set [report v] to (join (report) (item (count) of [list v]))
end
else
set [report v] to (item (1 v) of [list v])
set [count v] to [1]
repeat ((length of [list v]) - (1))
change [count v] by (1)
set [report v] to (join (report) (join [] (item (count) of [list v])))
end
end

Bugs

Due to the nature of the Scratch interface, it was possible to create an input on a List block by entering %m, %n, or %s. This was fixed in v423 or later.

It is possible to rename variables, but it's not possible to rename lists.

Entering
%m, %n, or %s will create the correspond-
ding input in the () block.

See Also

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