Unable to remove objects
BlitzMax Forums/BlitzMax Beginners Area/Unable to remove objects
| ||
I have already posted this in the forum for Brucey's modules, but got not answer, so I want to give it a last try asking here and hoping for more readers. The problem is that I can't remove objects from a list after saving and loading the list with the persistence.mod. Clearing the list with "list.clear" works. But no chance with "remove" or "=NULL". SuperStrict Import BaH.persistence Local alien:TAlien = New TAlien ' create one object in TAlien.list ' save TAlien.list Local tp:TPersist = New TPersist tp.SerializeToFile(TAlien.list, "TAlienlist.txt") ' Clear the list TAlien.list.Clear ' reload the list tp.DeSerializeFromFile("TAlienlist.txt") For Local toclear:TAlien = EachIn TAlien.list ' remove all objects in list ' toclear = Null ' does not work toclear.remove 'does not work although Next ' TAlien.list.Clear() ' this works and removes all objects.. DebugLog ("Listsize TAlienlist:" + TAlien.list.Count()) ' =1 (there is always one object left) Type TAlien Global list:TList = New TList Field link:TLink ' Method New() link = list.AddLast(Self) End Method ' Method Remove() link.Remove() End Method End Type |
| ||
sorry... this seems to work : For Local toclear:TAlien = EachIn TAlien.list ' remove all objects in list TAlien.list.remove(toclear) Next |
| ||
Yeah! Works. I hope I do not have to understand why this works and the other ways not.. |