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

Re: Passing zero as a Parameter/ NOT KEYWORD_SET



J.D. Smith (jdsmith@astrosun.tn.cornell.edu) writes:

> That's a bit dangerous.  IDL may have strange semantics and constructs,
> but that's no reason not to learn them.  I recommend peeking at a bit of
> IDL source code available all over the web.  You'll find common
> constructs such as:
> 
> ; give foo a default value if it is undefined.
> if n_elements(foo) eq 0 then foo=5  
> ; perform some action if flag is defined and non-zero
> if keyword_set(flag) then compute_something 
> ; return something to the caller if var is available to them (by
> reference)
> if arg_present(var) then var=compute_something_else() 

Ah, finally, some sense on this topic! Thanks, JD.

I lost my news feed yesterday and the article I posted on this
topic got eaten by DejaNews (probably fortunately). But nothing
causes more confusion for users than these three totally misnamed
functions: N_Elements, Keyword_Set, and Arg_Present. 

I'm in the process of writing an article on the subject for my
web page right this minute. (Why I haven't done it before is
a mystery. It's the single most misunderstood programming
feature I see in my travels.) It will be on my site sometime
this afternoon (Colorado time).

   http://www.dfanning.com/tips/keyword_check.html

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