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 #27023 is a reply to message #26552] Mon, 08 October 2001 09:27 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
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.

The paranoid may therefore use:

if n_elements(key) ne 0 then if keyword_set(key[0]) then do_something

or do you contend that key=[1,0] should also be "false"?

JD
[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: Sat Oct 11 09:42:00 PDT 2025

Total time taken to generate the page: 3.19935 seconds