undeclaring variables
Jon Loldrup
Posts: 14
Is it possible to undeclare variables in a BS2? I can't find anything about it in the reference manual.
/jon
/jon
Comments
MyTemp VAR BYTE
MyOtherTemp VAR MyTemp
Why would you want to "undeclare" a variable? Just don't declare it in the first place. You've only got 26 bytes, and 2000 bytes of program storage. Doing something you intend to undo later -- well, there's not a lot of resources available to devote to that sort of thing.
Couldn't you just reuse one that you have already declared and no longer need, assuming it was the correct type?
A good example is the variable you must declare as the loop index variable for a FOR/NEXT loop. When the loop is finished, you can set that variable to zero (or any other value up to the maximum type size) and use it for anything you want.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I find that when a variable is only to be used temporarily it’s good to give it such a name…temp, work or something that doesn’t lock it to a specific use. I re-use variables all the time and try to give those variables useful but more general names such as ioByte or ioData. As has been said previously you can always re-use the variable space for something else. Just remember that it won’t be un-initialized (0) at that point so remember that before you use it. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
that should do the job
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
/jon