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

Home » Public Forums » archive » CASE statement
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: CASE statement [message #27039 is a reply to message #26552] Mon, 08 October 2001 00:19 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Timm Weitkamp wrote:
>
> Paul van Delst <paul.vandelst@noaa.gov> wrote in messagenews:<3BBE2163.F73A162D@noaa.gov>...
>> "Pavel A. Romashkin" wrote:
>>>
>>> Timm Weitkamp wrote:
>>>>
>>>> It actually also has some counterintuitive features. This one, for
>>>> example:
>>>>
>>>> IDL> PRINT, KEYWORD_SET([0])
>>>> 1
>>>
>>> Correct me if I am wrong, but the PURPOSE of KEYWORD_SET is to check if
>>> a KEYWORD is SET. Settable keywords are those that you either set or
>>> don't, either /K_SET or K_SET=0. As such, they should not be set to
>>> arrays. As far as I can see, Keyword_Set is a convenience function. For
>>> value passing keywords, N_elements should be used.
>>> So, it looks to me that the name of this function means exactly what it
>>> is designed for.
>>
>> Excellent point.
>>
>> paulv
>
> Pavel and Paul,
>
> I mostly agree with you. But when you're programming a routine, even
> if you do use KEYWORD_SET in the strictly limited context that it
> should be, it is still possible that the user of the routine
> accidentally passes [0] (or [1]) instead of 0 (or 1) if the keyword is
> passed as an expression and not as an explicit value as in Pavel's
> example. Of course you may then blame the user, but that is of limited
> help.
>
> Timm

Dear Timm,

you can never use a one element vector by IF Statements or e.g. by
the WHERE command for comparison.


a=findgen(10)
print,where(a eq [1])
IDL > -1


IDL> if [1] eq [1] then print,'aa'
% Expression must be a scalar in this context: <BYTE Array[1]>.
% Execution halted at: $MAIN$


Of course it's not fine that's KEYWORD_SET don't crash if it is
used with [1] or [0].
But if your arguments could be arrays then
it is not the best way to use KEYWORD_SET. As Pavel explained
this function is only useful to distinguish between true (1) and
false (0). In addition the variable for keyword_set could be
a positional parameter too.

This is shown by the two excercises. The result in both tabulars
must be the same. If you don't believe try the examples.


Reimar


--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL LINUX support question
Next Topic: interpol

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

Current Time: Sun Nov 30 20:20:21 PST 2025

Total time taken to generate the page: 1.11829 seconds