Re: delete variable name from memory [message #44259] |
Thu, 02 June 2005 10:21  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Thu, 02 Jun 2005 14:25:46 +0200, David Fanning wrote:
> saplizki@gmail.com wrote:
>
>> I need to delete my variable from the variable name list.
>> but i don't locate at the top level (i'm in a gui program) so i can't
>> 'delvar' it.
>> also i can't (don't want to) zero it because it won't remove from the
>> variable list (when i press help or use ROUTINE_NAMES or ROUTINE_INFO)
>> and i use that list at my program.
>
> Try UNDEFINE:
>
> http://www.dfanning.com/programs/undefine.pro
Note that there is a difference between a deleted variable and an
undefined variable:
IDL> a=12
IDL> help
% At $MAIN$
A INT = 12
IDL> delvar,a
IDL> help
% At $MAIN$
IDL> a=12
IDL> undefine,a
% Compiled module: UNDEFINE.
IDL> help
% At $MAIN$
A UNDEFINED = <Undefined>
IDL> print,routine_info('$MAIN$',/VARIABLES)
A
I.e. the TEMPORARY tricks leave a reference to the variable as
UNDEFINED, whereas DELVAR removes any notion of ever having seen such
a variable. They are equivalent if you are using, e.g., N_ELEMENTS()
eq 0 as a test for a variable's presence, since whether a variable is
non-existent, or exists but is undefined, N_ELEMENTS is 0. An
undefined variable, however, is still a variable, and will show up in
ROUTINE_INFO, among other places.
JD
|
|
|
|
|
|