List not behaving

Jamie

Member
Licensed User
Longtime User
Hi. I have this code that is driving me crazy.
B4X:
Dim temp As String
      temp = cells(4) 'hold value
      cells(4)="" 'remove this value ... shouldn't go in newlist
      newlist.add(cells) 
      Log(cells(0)&cells(1)&cells(2)&cells(3)&cells(4)) ' "" is in cell(4)
      cells(4) = temp 'replace original value ' if this line isn't commented out the value will end up in newlist
      Log(cells(0)&cells(1)&cells(2)&cells(3)&cells(4))

As the comments show if I cell(4) = temp "after" newlist.add(cells) the value I was holding in temp ends up in newlist.
If I comment out cell(4) = temp then it doesn't go into newlist.add(cells)
My guess is that the code completes in the sub and newlist.add(cells) happens after the sub completes, so the cells(4) has been refilled with the value before newlist is written.
Have I got this right because it's driving me crazy............. :BangHead:
 
Top