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

Home » Public Forums » archive » Re: keyword_set bug or feature
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: keyword_set bug or feature [message #4214 is a reply to message #4212] Fri, 12 May 1995 00:00 Go to previous message
peter is currently offline  peter
Messages: 80
Registered: February 1994
Member
Phil (phil@peace.med.ohio-state.edu) wrote:
: Thanks to those who responded to my ? concerning common blocks.

: I just can across another 'feature' and was wondering if others felt
: that it is really a 'bug' or if there is some way to over come it. It
: has to do with keywords in functions or procedures. I use several and
: check to see if the are set using

: IF NOT(keyowrd_set(key)) THEN BEGIN
: ;set a default value here
: ENDIF

: The problem comes in if the user wants to set key = 0. If so then it
: appears to the above test that the keyword is not set even though in
: the function call the user typed
:
: Result = somefunction(var,key=0)

: What gives? Can I just add key = key + 1 and key = key - 1 around the
: testing if statement?


This is the specified behavior of keyword_set, and yes, it has caused
problems for others (i.e. me!). The solution to your problem is to
used n_elements(key) to test whether any value was set, or no value
at all. n_elements will return 0 on an undefined variable, and 1
on any scalar, including 0.

Peter
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Plotting to file
Next Topic: Re: Bad pixmap error, pixmap allocation, keywords

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

Current Time: Sat Oct 11 14:44:22 PDT 2025

Total time taken to generate the page: 0.63961 seconds