[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keyword question

Randall Skelton (rhskelto@atm.ox.ac.uk) writes:
> I am trying to have an array *optionally* returned using a keyword
> and I don't know the dimension of the array prior to the call.  Why is
> it that the passed keyword needs to be defined in IDL prior to being used
> as a keyword?  
> What am I doing wrong here?

You are using the wrong function to check the keyword.
KEYWORD_SET should *only* be used to test keywords that
have a binary function. That is, they are either on or off,
true or false, 0 or 1, etc.

What you want to know is if you keyword is *defined* or
not. You use N_ELEMENTS to tell you this:

   IF N_Elements(b) EQ 0 THEN b = FltArr(10)

Here is an article containing more information on this




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