Item number of () in (): Difference between revisions
Item number of () in ()
Content deleted Content added
No edit summary |
m Added see also, display title, and used blockcat |
||
Line 6: | Line 6: | ||
}} |
}} |
||
{{Incorrect Title|item # of () in ()}} |
{{Incorrect Title|item # of () in ()}} |
||
The '''item # of () in ()''' block is a reporter block in the [[Lists]] subcategory that reports the item number of the first occurrence of the inputted item in the selected list. It was introduced in Scratch 3.0. |
The '''item # of () in ()''' block is a reporter block in the [[Lists]] subcategory that reports the item number of the first occurrence of the inputted item in the selected list. It was introduced in [[Scratch]] 3.0. |
||
==Workaround== |
==Workaround== |
||
This block can be worked around using the following code: |
This block can be worked around using the following code, which iterates over the items in the list and checks for the first match: |
||
<scratchblocks> |
<scratchblocks> |
||
define find item # of (string1) |
define find item # of (string1) |
||
Line 17: | Line 17: | ||
end |
end |
||
end |
end |
||
return (item number) |
return (item number)::custom cap |
||
</scratchblocks> |
</scratchblocks> |
||
==See also== |
|||
[[Category:Reporter Blocks]] |
|||
*[[index of () in ()]] |
|||
[[Category:Vanilla Blocks]] |
|||
*[[last index of () in ()]] |
|||
[[Category:List Blocks]] |
|||
{{DISPLAYTITLE:item # of () in ()}} |
|||
{{Blockcat|cat=List|type=Reporter|sc=y}} |
Revision as of 22:52, 8 July 2024
item # of () in () | |
---|---|
item # of [] in [ v] | |
Block Type | Reporter Block |
Category / Extension | Lists |
- The correct title of this article is item # of () in (). PenguinMod Wiki uses Item number of () in () instead because of technical restrictions.
The item # of () in () block is a reporter block in the Lists subcategory that reports the item number of the first occurrence of the inputted item in the selected list. It was introduced in Scratch 3.0.
Workaround
This block can be worked around using the following code, which iterates over the items in the list and checks for the first match:
define find item # of (string1) set [item number v] to [0] //keep track of the item in the list if <[list v] contains (string1)?> then repeat until <(item (item number) of [list v]) = (string1)> change [item number v] by (1) end end return (item number)::custom cap