You can try something like this:
when gf clicked set [counter v] to [0] repeat (length of [list v]) change [counter v] by (1) if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] end end
Offline
jvvg wrote:
You can try something like this:
when gf clicked set [counter v] to [0] repeat (length of [list v]) change [counter v] by (1) if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] end end
Actually, that wouldn't work 100% of the time.
For example, lets say that we want to remove "pie" from the list and we have this list:
candy
pie
pie
chocolate
As soon as your script removes the first "pie", it will move onto the "chocolate" and entirely skip the second "pie", so this is the script I would use:
when gf clicked set [counter v] to (1) repeat until <not <[list v] contains [whatever you want to remove]>> if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] else change [counter v] by (1) end end
Offline
ErnieParke wrote:
jvvg wrote:
You can try something like this:
when gf clicked set [counter v] to [0] repeat (length of [list v]) change [counter v] by (1) if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] end endActually, that wouldn't work 100% of the time.
For example, lets say that we want to remove "pie" from the list and we have this list:candy
pie
pie
chocolateAs soon as your script removes the first "pie", it will move onto the "chocolate" and entirely skip the second "pie", so this is the script I would use:
when gf clicked set [counter v] to (1) repeat until <not <[list v] contains [whatever you want to remove]>> if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] else change [counter v] by (1) end end
Smart.
Offline
ImagineIt wrote:
ErnieParke wrote:
jvvg wrote:
You can try something like this:
when gf clicked set [counter v] to [0] repeat (length of [list v]) change [counter v] by (1) if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] end endActually, that wouldn't work 100% of the time.
For example, lets say that we want to remove "pie" from the list and we have this list:candy
pie
pie
chocolateAs soon as your script removes the first "pie", it will move onto the "chocolate" and entirely skip the second "pie", so this is the script I would use:
when gf clicked set [counter v] to (1) repeat until <not <[list v] contains [whatever you want to remove]>> if <(item (counter) of [list v]) = [whatever you want to remove]> delete (counter) of [list v] else change [counter v] by (1) end endSmart.
Thanks you.
Edit: Wait, shouldn't this be in Help with Scripts and not Questions about Scratch?
Last edited by ErnieParke (2012-09-30 15:56:59)
Offline