Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Identify an item in the list according to what it contains
- vajei
-
Scratcher
99 posts
Identify an item in the list according to what it contains
How do I do what's in the title?
- musicROCKS013
-
Scratcher
1000+ posts
Identify an item in the list according to what it contains
set [i v] to [0]
repeat until <(item (i) of [list v] :: list) contains [apple]::operators>//doesn't have to be "apple." It can be whatever
change [i v] by (1)
end
Last edited by musicROCKS013 (July 17, 2022 03:02:38)
- NeonG4
-
Scratcher
1000+ posts
Identify an item in the list according to what it contains
clipped
if <[list v] contains [apple] ?> then
set [i v] to [0]
repeat until <(item (i) of [list v] :: list) contains [apple]::operators>//doesn't have to be "apple." It can be whatever
change [i v] by (1)
end
end
- abcde1234qwe
-
Scratcher
500+ posts
Identify an item in the list according to what it contains
snip
snipThat code only detects 1 item. If there are 2 or more items, it won't detect those items.
//Note: This script only works if you are deleting the items.
set [i v] to [1]
repeat until <not <[list v] contains [apple] ?>>
if <not <(item (i) of [list v] :: list) contains [apple]::operators>> then
change [i v] by (1)
else
code that deletes the item or something::grey
end
end
//Note: This script works if you aren't deleting the item.
if <[list v] contains [apple] ?> then
set [i v] to [1]
delete all of [list2 v] :: list
repeat (length of [list v] :: list)
if <[list v] contains [apple] ?> then
repeat until <(item (i) of [list v] :: list) contains [apple]::operators>//doesn't have to be "apple." It can be whatever.
change [I v] by (1)
end
add (item (i) of [list v] :: list) to [list2 v]
end
end
end
Last edited by abcde1234qwe (July 17, 2022 03:54:48)
- Discussion Forums
- » Help with Scripts
-
» Identify an item in the list according to what it contains



