ForEach Function where you can remove items.

Feature requests for future versions of Hollywood can be voiced here
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

ForEach Function where you can remove items.

Post by Bugala »

quite typical use for myself would be:

Code: Select all

ForEach(table, function (index, value)
                                                      if something, as example, value=searcheditem  then removeitem(table, index)
                                              endfunction)
I can still do this, but i need to do it with two ForEaches, first Foreach will be:

Code: Select all

t_temptable = {}
ForEach(table, function (index, value)
                                                      if something, as example, value=searcheditem  then insertitem(t_temptable, index)
                                              endfunction)
after which i do the other foreach of:

Code: Select all

ForEach(t_temptable, function (index, value)
                                                      removeitem(table, value)
                                              endfunction)
This is not a big deal, since you can do it this way, but it would be much handier if you could do this with one ForEach command only.

It could be something like ForEachCopy(), or even additional argument, as right now arguments are ForEachCopy(table, function) it could be ForEachCopy(table, function, copy) where copy would be True or False.

Meaning that it would inside hollywood make a copy of that table and then go through that copy instead of the original, but when using removitem (or similarly table affecting commands) it would instead of affecting the copy that it is going through, will be using that command to the original table.

And naturally after foreach is done, that copy would automatically be destroyed.
Post Reply