comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to see if variable is defined?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to see if variable is defined? [message #3357] Sat, 21 January 1995 10:22
ps is currently offline  ps
Messages: 14
Registered: September 1994
Junior Member
Ralph Finch (rfinch@water.ca.gov) wrote:
: Is there a nice way of checking if a variable is defined?

: I have a widget_control command which removes a menu, and I need to
: see if the menu is defined before destroying it.
: --
: Ralph Finch 916-653-8268:voice 916-653-6077:fax
: rfinch@dop.water.ca.gov / finger for PGP public key
: "Nada burra la chamaca." A.G.
: Any opinions expressed are my own; they do not represent my employer

examine size(var). if s(s(0)+1) equal zero, var is undefined.
Or try the function keyword_set. But it has some problems if the
variable to be examined is zero.

Peter

------------------ Peter 'PIT' Suetterlin -----------------
| Kiepenheuer Institut | Sternfreunde Breisgau e.V |
| fuer Sonnenphysik | |
| 0761/3198-210 | 0761/71571 |
-<ps@kis.uni-freiburg.de>-<suettpet@sun1.ruf.uni-freiburg.de>--
Re: How to see if variable is defined? [message #3358 is a reply to message #3357] Sat, 21 January 1995 09:04 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <RFINCH.95Jan20094331@venice.water.ca.gov>, rfinch@water.ca.gov (Ralph Finch) writes:
> Is there a nice way of checking if a variable is defined?
>
> I have a widget_control command which removes a menu, and I need to
> see if the menu is defined before destroying it.

n_elements will tell you if a variable is defined:

IDL> print, n_elements(myvar)

will be 0 if myvar is not defined, 1 if myvar is a scalar, else number of
elements in array.

____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL on OSF V3.0
Next Topic: Re: Nice Postscript output from shade-surf? Xsize in polyshade?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 08:02:01 PDT 2025

Total time taken to generate the page: 1.68262 seconds