Page 1 of 1

Unsetting a variable?

Posted: Fri Jul 13, 2007 9:19 am
by Mistrel
Is there a way to "unset" a variable similar to php's unset()?

Posted: Fri Jul 13, 2007 1:37 pm
by Flype
no you can't (as far as i know).

local vars (in procedures) are automatically unset when exiting the proc.

others vars are unset when exiting the app.

the only thing you can do is to 'nullify' your var ( myvar = #Null, myvar$ = #Null$ ) but it's not an 'unset'.

Posted: Fri Jul 13, 2007 3:27 pm
by JonChaos
A workaround would be adding your variables to a linked list.
But that would add a lot of cpu and memory overhead so its only usefull if you have a lot of dynamic memory assignment going on.

In most cases its a waste of resources thougth.

Posted: Fri Jul 13, 2007 5:26 pm
by JonChaos
Another option would be allocating memory with AllocateMemory(Size) and work with Peek / Poke.
If the memory isnt used anymore you could free it with FreeMemory(*MemoryID) .

Posted: Fri Jul 13, 2007 9:09 pm
by blueznl
People ignore the main question: why would you want to do such a thing?