From Test-Scratch-Wiki
| () | |
(list :: list) | |
| 类别 | 清单类积木 |
| 形狀 | 椭圆形积木 |
| 加入於 | 1.3 |
The () 积木 is a 清单类积木 and a 椭圆形积木. The block simply reports the items of its 清单 as a 字串.
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 舞台监控视窗.
A space is put between each item when it is called. If the length of all of the 项目s in a list is equal to 1, no space is put between the items.
用法示例
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
說出 (sentence :: list)
- Setting a 变量 to the value of this block so that a list local to a sprite can be transferred
變數 [unlock v] 設為 (list :: list)
应用
- Main article: List of Block Workarounds
This block can be replicated with the following code:
變數 [count v] 設為 [0]
變數 [all are 1 v] 設為 [true]
重複直到 <<(all are 1) = [false]> 或 <(count) > (清單 [list v] 的項目數 :: list)>>
變數 [count v] 改變 (1)
如果 <(字串長度\( (清單第 (count) 項項目\( [list v] \) :: list) \))) > [1]> 那麼
變數 [all are 1 v] 設為 [false]
end
end
如果 <(all are 1) = [true]> 那麼
變數 [report v] 設為 []
變數 [count v] 設為 [0]
重複 (清單 [list v] 的項目數 :: list) 次
變數 [count v] 改變 (1)
變數 [report v] 設為 (字串組合 (report) 和 (清單第 (count) 項項目\( [list v] \) :: list))
end
否則
變數 [report v] 設為 (清單第 (1 v) 項項目\( [list v] \) :: list)
變數 [count v] 設為 [1]
重複 ((清單 [list v] 的項目數 :: list) - (1)) 次
變數 [count v] 改變 (1)
變數 [report v] 設為 (字串組合 (report) 和 (字串組合 [] 和 (清單第 (count) 項項目\( [list v] \) :: list)))
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.
参见
| Zho:变数类积木 | |
| Zho:清单类积木 |
()
• 新增项目 () () • 删除第 () 项 () • 添加 () 为第 () 项 • 替换第 () 项于 () 成 () • 清单第 () 项项目 () • 清单 () 的项目数 • 清单 () 包含 () • 清单 () 显示 • 清单 () 隐藏更多积木… |