Can RemoveItem affect item 0?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Can RemoveItem affect item 0?

Post by Bugala »

I am having a bug which makes no sense.

Idea is that to have my items in list in right order, I am adding "empty" item to list location 0, since otherwise the first item (0) would be executed first. However, this "empty" item is there only temporary and is removed after the loop:

Code: Select all

Insertitem(t_table, "empty", 0)

foreach(t_table, Function (cell, data)
if cell = "empty" then return
other stuff to be done
endfunction )

removeitem(t_table, 0)
Now problem is, some strange way this "empty" ends up staying there in one case causing a crash bug, and i cant really figure out what is causing this.

So far only line that has anything to do with tables inside that function seems to be that I am using RemoveItem for t_tables items that are greater than 0 in some cases.

Therefore, is there any possibility that when for example item number 2 would be removed using RemoveItem, that Item number 0 would change its spot to some other number location?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Can RemoveItem affect item 0?

Post by airsoftsoftwair »

Item 0 could only change its position in the list if another item is inserted in front of it. RemoveItem() should never affect item 0.... unless you explicitly specify 0 as the parameter :)
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Can RemoveItem affect item 0?

Post by Bugala »

And just to comfirm, only way to affect item 0 with insertitem would be to use
Insertitem(table, item, 0), right?
that just insertitem(table, item) would never affect item in location 0?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Can RemoveItem affect item 0?

Post by airsoftsoftwair »

Yes.
Post Reply