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

Home » Public Forums » archive » Re: Passing zero as a Parameter/ NOT KEYWORD_SET
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: Passing zero as a Parameter/ NOT KEYWORD_SET [message #16119 is a reply to message #16118] Mon, 28 June 1999 00:00 Go to previous messageGo to previous message
philaldis is currently offline  philaldis
Messages: 32
Registered: March 1999
Member
On Mon, 28 Jun 1999 09:08:04 -0400, Grady Daub
<gadZOOKS8371@garnet.acns.fsuMMER.edu> wrote:

> How can I pass the number zero as a parameter, without the
> function/subroutine thinking that the parameter is not set?
>
snipped
>
> IF NOT KEYWORD_SET(keyword) then do-this-stuff
>
> not work?
>
> I've had to do the following:
>
> IF KEYWORD_SET(keyword) then a=a else do-this-stuff
>
> ("a=a" acts as some kind of dummy variable thing.)
>
>
> -Grady Daub
>
> (Remove MMER and ZOOKS to reply by e-mail.)
>
>

I presume that in your code your doing an

IF Keyword_Set() THEN BEGIN
.
.
define out
.
.
ENDIF

but Keyword_Set() is more suitable for flags, than parameters. The
best way to do it is use N_Elements(), which returns 0 if a variable
is undefined. So do :

IF N_Elements(in) THEN BEGIN
.
.
.
ENDIF

NOT when applied to an integer does funny twos complement or something
(I'm not treally sure so look at the IDL help if you're interested).
When NOT operates on floats, however, it just does the logical
inverse. So you could do:

IF NOT(Float(KEYWORD_SET(keyword))) THEN BEGIN

However the best way is just to do this:

IF KEYWORD_SET(keyword) EQ 0 THEN BEGIN

Remeber that KEYWORD_SET is a function and it returns 0 if the keyword
isn't set and 1 if it is. It's easy to get confused looking at the
syntax of IF Keyword_Set(keyword), and think that it is actually
asking if the keyword is set. In fact, IF KEYWORD_SET(keyword) is
merely shorthand for:

IF KEYWORD_SET(keyword) EQ 1

I hope this helps

Cheers,
Phil
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Zero vector detection in IDL
Next Topic: Re: Extra space around widget windows....

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

Current Time: Wed Oct 08 19:27:33 PDT 2025

Total time taken to generate the page: 0.00471 seconds