checking if variable is defined [message #24625] |
Wed, 11 April 2001 08:47  |
Dominik[1]
Messages: 46 Registered: April 2001
|
Member |
|
|
Helle there,
I would like to plot a variable, but only if it is existing. When the
Variable is undefined, nothing should happen. So I am searching for an
expression for the if statement. Does anybody know an expression like:
if ( vaiable_name existing) then...
Thanks
Dominik
--
_____________________________
Dominik Paul
dpaul@ukl.uni-freiburg.de
Universit�tsklinikum Freiburg
Abt. PET/Nuklearmedizin
|
|
|
Re: checking if variable is defined [message #24759 is a reply to message #24625] |
Thu, 12 April 2001 05:19  |
Bernard Puc
Messages: 65 Registered: January 1998
|
Member |
|
|
Dominik wrote:
>
> Helle there,
>
> I would like to plot a variable, but only if it is existing. When the
> Variable is undefined, nothing should happen. So I am searching for an
> expression for the if statement. Does anybody know an expression like:
> if ( vaiable_name existing) then...
One way to do this is with the N_ELEMENTS() function:
if (n_elements( variable ) GT 0) then print,'Variable exists'
--
Bernard Puc AETC, INC.
bpuc@va.aetc.com 1225 Jefferson Davis Highway #800
(703) 413-0500 Arlington, VA 22202
|
|
|
Re: checking if variable is defined [message #24774 is a reply to message #24625] |
Wed, 11 April 2001 09:59  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Dominik (dpaul@ukl.uni-freiburg.de) writes:
> I would like to plot a variable, but only if it is existing. When the
> Variable is undefined, nothing should happen. So I am searching for an
> expression for the if statement. Does anybody know an expression like:
> if ( vaiable_name existing) then...
IF N_Elements(variable_name) NE 0 THEN doSomething
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|