Re: axis problem [message #35777 is a reply to message #35776] |
Sun, 20 July 2003 10:08   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Reimar Bauer writes:
> David I can't agree
>
> It can't be that the user program has to test what keywords values are
> set as default by a routine and if it has this value then it must be
> killed from the _extra structure if it is there.
>
> With all the other keywords it works as supposed. It would be very bad
> if it is somewhere defined that's the user is not able to pass default
> values by _extra. It must be possible to switch back to the whatever
> default value by submitting 0 for example.
>
> At the moment I believe there is a bug with the querying of xyz minor.
> They used keyword_set() instead of n_elements() and ...
I'm not so sure of my answer that I would bet a
whole lot of money on the "no bug" theory, but still...
Think of how you would do this. A keyword has a value of 5 by
default. If the keyword is set to 0, you which to set the
value to 5. You would write the program like this:
PRO MyPlot, KEY=key, _Extra=extra
IF N_Elements(key) EQ 0 THEN key = 5
IF key EQ 0 THEN key = 5
PLOTSOMETHING, Key=key, _Extra=extra
END
Now, if you pass a value in with the keyword, you encounter
the "processing".
IDL> MyPlot, KEY=0
If you pass it in via the _EXTRA mechanism, you bypass
the processing:
IDL> MyPlot, _Extra={KEY:0}
This seems quite reasonable to me. The alternative would
be to put something like this into your program:
IF N_ELements(extra) NE 0 THEN BEGIN
tagnames = Tag_Names(extra)
index = WHERE(tagnames EQ 'K', count)
IF count GT 0 THEN IF extra.(index) EQ 0 THEN key = 5
index = WHERE(tagnames EQ 'KE', count)
IF count GT 0 THEN IF extra.(index) EQ 0 THEN key = 5
index = WHERE(tagnames EQ 'KEY', count)
IF count GT 0 THEN IF extra.(index) EQ 0 THEN key = 5
ENDIF
Think what would happen if you wrote a long keyword name,
or if you had multiple keywords defined that you had to
chase down like this. You would spend all your time writing
code and no time at all drinking beer. :-(
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|