Re: CONTTW.PRO and EXPAND.PRO - some bug fixes, enhancements [message #560 is a reply to message #559] |
Fri, 09 October 1992 05:37   |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
In article <BvuroD.60q@news.larc.nasa.gov>, zawodny@arbd0.larc.nasa.gov (Dr. Joseph M Zawodny) writes...
> I guess to each his own. I do admit that the autoscaling was crude at best.
> I included it, for the same reason PV-WAVE has a point and click interface,
> there are managers out there who still like to play with data that they know
> little about ;-) . I will take exception to the alleged "misuse" of
> keyword_set. The only time n_elements is preferable to keyword_set is when the
> keyword needs to allow zero to be a "good" value or when you need to know
> whether the keyword is a scalar or an array. IMHO the first exception is more
> of a bug. Zero should not be considered a sign of a non-set keyword, an unset
> keyword has no value (be nice if the good folks at RSI could follow up on
> this). Just to reiterate the tone of the original posting, I posted it so that
> people could hack it to suit thier needs. I'm happy to see it was of some use
> to someone.
It's not a bug. "Set" keywords take true or false values. In IDL (as in most
languages), false values are encoded as zero. Joseph Zawodny is suggesting
instituting a whole new data type to do the same thing for keywords.
When passing keywords from higher level routines to lower level routines, it is
imperative that there be a value to pass from one routine to the next.
Otherwise, how could one do the following
PRO DUMMY1,KEY=KEY,...
...
DUMMY2,KEY=KEY,...
...
END
PRO DUMMY2,KEY=KEY,...
...
END
In other words, how could you take the value of KEY that was (or was not)
passed to DUMMY1 and pass it on to DUMMY2?
Also, you can pass the true/false value of the keyword directly. You don't
have to use the /KEY form. You can call
DUMMY1,KEY=0,...
or
DUMMY1,KEY=myvalue,...
which is a lot better than
IF myvalue THEN DUMMY1,/KEY,... ELSE DUMMY1,...
The upshot is, use KEYWORD_SET only for keywords that take true/false values,
and use N_ELEMENTS to test whether a non-T/F keyword was passed or not.
Bill Thompson
|
|
|