This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-08-31 19:08:07

warriorcats3125
Scratcher
Registered: 2012-02-11
Posts: 100+

Deleting a specific item from a list

This may have already been suggested...
I think it would be nice if, instead of being able to only delete and replace items at a certain position in a list, people could type a specific item and have that specific item deleted or replaced from the list. At the moment, it is only possible to delete and/or replace items at certain positions in a list. We could also have blocks that would detect if a certain item was in a list.
We could have blocks that would look like this:

if <item [ball] is in list [inventory v]>
delete item [ball] of list [inventory v]
end
if <item [ball] is in list [inventory v]>
replace item [ball] of list [inventory v] with item [car]
end


The angels have the phone box...
http://i46.tinypic.com/244bp1h.jpg

Offline

 

#2 2012-08-31 19:13:14

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Deleting a specific item from a list

that would be useful but the scratch team rarely adds features with workarounds.

set [c v] to (1)
repeat until <(c) > (length of [inventory v])>
if <(item (c) of [inventory v]) = [ball]>
delete item (c) of [inventory v]
else
change [c v] by (1)
end
end

Last edited by Wes64 (2012-08-31 19:13:37)


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#3 2012-08-31 19:36:06

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Deleting a specific item from a list

That would be cool, but what would happen if there were duplicates of an item? Would it delete the first, both, or what? :S


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#4 2012-08-31 19:53:34

warriorcats3125
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: Deleting a specific item from a list

Jonathanpb wrote:

That would be cool, but what would happen if there were duplicates of an item? Would it delete the first, both, or what? :S

The blocks would delete both or the blocks could look like this:

if <item [ball] is in list [inventory v]>
delete instance [1 v] of item [ball] of list [inventory v]
end
if <item [ball] is in list [inventory v]>
replace instance [1 v] of item [ball] of list [inventory v] with item [car]
end


The angels have the phone box...
http://i46.tinypic.com/244bp1h.jpg

Offline

 

#5 2012-08-31 23:41:40

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: Deleting a specific item from a list

This would be nice, though, as Wes said, there is a somewhat cumbersome workaround.  smile


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

#6 2012-09-01 05:12:50

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Deleting a specific item from a list

<[list v] contains [thing]>
is the
<item [] is in  list [list v]>
you have put in the topic post.

The delete block you said has a workaround, as pointed out by wes64


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#7 2012-11-12 05:53:50

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Deleting a specific item from a list

Closed by request of the topic owner.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer