Delete Objects

BlitzMax Forums/BlitzMax Beginners Area/Delete Objects

(tu) ENAY(Posted 2005) [#1]
Ok, so I've got my Types and Lists all going ok.

But I can't seem to figure out how to delete an object once I've created it using New and .AddList commands

.Reset seems to work and compile but doesn't seem to get rid of the object. Can someone help? :)


Dreamora(Posted 2005) [#2]
You can't
They are automatically freed when you call flushmem if there is no reference pointing to them anymore.

Normally you control this by putting them in a handling list and if you want to free them you remove them from there.
But this only works if other objects don't point to them.


(tu) ENAY(Posted 2005) [#3]
But Flushmem destroys everything doesn't it? So you're saying you can't delete individual objects either in a type list?


Amon_old(Posted 2005) [#4]
look for "ListRemove" in the docs. It'll be something like "ListRemove mylist,myobject"

"RemoveLink" is also an option. It states that RemoveLink is more efficient than ListRemove but I have as yet had no problems with ListRemove.


Dreamora(Posted 2005) [#5]
Flushmem does not destroy everything. It only frees unreferenced objects (-> objects that aren't used anymore)


(tu) ENAY(Posted 2005) [#6]
I'll have a look for ListRemove, but by the sounds of it, I can't understand why deleting is so tricky.
Why can't it just be new and delete like in the original Blitz data Types?


(tu) ENAY(Posted 2005) [#7]
DOH! Just put .Clear() back in again and this time it works!?!

Ah well, at least I'm sorted now. Thanks guys, at least it *IS* possible to delete a list.