Note: This is an archived post that was originally sent to the Hollywood mailing list on 09 Aug 2009 14:54:30 +0000
Hello,
was it already known that there is a problem with RemoveItem() when doing this on the first item? If there is only one row the example below works too. What makes me wondering too, is that I have to bring in another helpervariable to make it work for any other row than the first. If not, this codesnippet fails when removing the first row, whenever there is more than one row:
Function p_RemoveClub()
Local id = StringRequest("Enter ID","Enter ID of Club to remove","0")
If (id <> "" AND id <>"0")
If ClubCount > 0
For i = 0 To ClubCount-1
If ToString(t_club[i][0]) = id
/*Entry To be removed got identified*/
y = i
For t=(ListItems(t_club[y])-1) To 0 Step -1
RemoveItem(t_club[y])
Next
ClubCount = Sub(ClubCount,1)
Break
ElseIf(t_club[i][0] > id)
Break
EndIf
Next
EndIf()
EndIf()
EndFunction
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 12 Aug 2009 00:28:24 +0200
Hello,
was it already known that there is a problem with RemoveItem() when doing this on the first item? If there is only one row the example below works too. What makes me wondering too, is that I have to bring in another helpervariable to make it work for any other row than the first. If not, this codesnippet fails when removing the first row, whenever there is more than one row:
I'd bet that there's a mistake in your code because RemoveItem() is a lua function and this shouldn't have any problems.. if you still think that there's a bug in RemoveItem(), please provide a smaller code snippet. The one you provided is too complicated and I don't really know what it does. Try to break it down
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 12 Aug 2009 15:22:16 +0200
Hello guys,
when stripping down the example, I got some strange behaviour. When removing the only row of a table, it is removed with the respective value. When adding two rows and removing the first again, the returnvalue is nil... please have a look:
@VERSION 4,0
CtrlCQuit(True)
EscapeQuit(False)
EnableLayers()
Function p_defTab(tabname,n,x,y)
For i = n To x-1
tabname[i] = {}
For j = 0 To y
tabname[i][j] = "0"
Next
Next
EndFunction
Function p_delTabrow()
For i = 0 To 5
e = RemoveItem(t_masterdata[0])
Print(i," .. ",e,"\n")
Next
EndFunction
/*FLOW BEGINS: !!*/
/*define empty table*/
Global t_masterdata = {}
/*Add one row*/
p_defTab(t_masterdata,ListItems(t_masterdata),(ListItems(t_masterdata)+1),5)
/*remove one row*/
Print("START REMOVING\n")
p_delTabrow()
/*Add two rows*/
p_defTab(t_masterdata,ListItems(t_masterdata),(ListItems(t_masterdata)+1),5)
p_defTab(t_masterdata,ListItems(t_masterdata),(ListItems(t_masterdata)+1),5)
/*remove one row*/
Print("\nSTART REMOVING again\n")
p_delTabrow()
Print("\nPress LMB to exit")
WaitLeftMouse()
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 13 Aug 2009 00:24:54 +0200
Hello guys,
when stripping down the example, I got some strange behaviour. When removing the only row of a table, it is removed with the respective value. When adding two rows and removing the first again, the returnvalue is nil...
It is Nil because you're not removing the row table. You are removing just the elements of the row table but not the table itself. Remember that you have a two dimensional table! Here's how it must look:
Function p_delTabrow()
For i = 0 To 5
e = RemoveItem(t_masterdata[0])
Print(i," .. ",e,"\n")
Next
;*******************************************************
RemoveItem(t_masterdata, 0) ; add this and it will work
;*******************************************************
EndFunction