用积木编辑列表
-
先修科目
说明
使用积木可以轻松地编辑列表,比如新增项、删除项、修改项的值。
附加新项
这个积木用于在列表底部增添新项。每当运行这个积木,列表长度就增加1。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/48958474-db6b-4402-9cd0-bef7093ddbb6.png" width="300" style="">
参数
- 值:所加入的数字或文字。如果这个字段为空,就会向列表新增一个空项。
- 列表名:选择列表名。你需要先创建某个列表,然后才能在这个下拉菜单中选择该列表。
示例
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1cf87b9a-54a3-4d0d-8df1-fd1acf524b7f.gif" width="970" style="border-radius: 5px; border: 1px solid #29622d;">
插入新项
如果你要把新增项放在特定位置(而不是底部),就可以用积木“插入”。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f14f326b-d891-4499-aeb4-5f76eb65e354.png" width="420" style="">
参数
- 列表名:列表的名称。需要先手动添加至少一个列表。
- 索引号:新增项的位置。例如,如果列表有2项,索引号只能为1、2、3。
- 值:所加入的数字或文字。如果这个字段为空,就会向列表插入一个空项。
示例
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2c7d7403-72fe-4982-aceb-949fdabf24db.gif" width="970" style="border-radius: 5px; border: 1px solid #29622d;">
替换列表项
如果你知道某一项的索引号,就能修改这一项的值。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a837f337-4c83-4a1f-ba74-5706437893bd.png" width="400" style="">
参数
- 列表名:列表的名称。
- 索引号:被替换的项的位置。例如,如果列表有3项,索引号只能为1、2、3。
- 值:这一项的新值,也可以为空。
示例
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b93868aa-bc9c-46bb-9d82-31ab2f1b9baf.gif" width="970" style="border-radius: 5px; border: 1px solid #29622d;">
按照索引号删除列表项
如果你知道列表中某项的索引号,就可以用这个积木将其删除。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/38312ec6-41c6-45b9-ab22-0fdc301960c1.png" width="300" style="">
参数
- 列表名:列表的名称。
- 索引号:将被删除的项的位置。例如,如果列表有3项,索引号只能为1、2、3。
示例
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b044349f-7b8f-4bc0-a7bf-3e1d8b2581e0.gif" width="970" style="border-radius: 5px; border: 1px solid #29622d;">
按照值删除列表项
利用这个积木,你可以按照项的值删除某一项。如果你不知道这一项的索引号,但你知道其值,用这个积木就很方便。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c721243e-f92a-4fbd-8bd7-986085f0857c.png" width="300" style="">
参数
- 列表名:列表的名称。
- 值:将被删除的项的值。如果列表中找不到这个值,就没有项被删除。如果有多个项为这个值,只有第一项会被删除。
示例
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/e15d2849-579e-4581-b1e7-c4e43bfa5eea.gif" width="970" style="border-radius: 5px; border: 1px solid #29622d;">
删除全部项
这个积木会删除列表中的全部项,这个列表就变为空。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d5ee5df6-aa4d-46a1-8f8a-8e1090936008.png" width="270" style="">
继续学习
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login