Can I removeitem table?

Find quick help here to get you started with Hollywood
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Can I removeitem table?

Post by Bugala »

I am trying following:

Code: Select all

table = { ["item1"]="test1", ["item2"] = "test2"}

item = RemoveItem(table)
ForEach(table, DebugPrint)
What I was hoping to achieve was for either "item1" or "item2" with its "test1" / "test2" to disappear from table, however, they stay intact, which means it didnt work.

Is there any way I can actually make this happen?
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Can I removeitem table?

Post by SamuraiCrow »

The purpose of RemoveItem is to renumber the numerical keys in a Hollywood "array". Assigning the value corresponding to the first key to Nil in a one shot use of an iterator is what you are trying to do, it seems.

Use NextItem to get the first key, use item=table[key] to get the value, then use table[key]=Nil to remove it from the table.
I'm on registered MorphOS using FlowStudio.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Can I removeitem table?

Post by Bugala »

Thanks, that is at least better than the alternatives i was thinking.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Can I removeitem table?

Post by SamuraiCrow »

After some thoughts, perhaps the first two steps of my suggested solution can be combined by using the second returned value on NextItem.
I'm on registered MorphOS using FlowStudio.
Post Reply