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

Home » Public Forums » archive » Re: keyword question
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 question [message #25216] Wed, 23 May 2001 09:35 Go to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
David Fanning wrote:
>
> Randall Skelton (rhskelto@atm.ox.ac.uk) writes:
>
>> I am trying to have an array *optionally* returned using a keyword
>> and I don't know the dimension of the array prior to the call. Why is
>> it that the passed keyword needs to be defined in IDL prior to being used
>> as a keyword?
>>
>> What am I doing wrong here?
>
> You are using the wrong function to check the keyword.
> KEYWORD_SET should *only* be used to test keywords that
> have a binary function. That is, they are either on or off,
> true or false, 0 or 1, etc.
>
> What you want to know is if you keyword is *defined* or
> not. You use N_ELEMENTS to tell you this:
>
> IF N_Elements(b) EQ 0 THEN b = FltArr(10)

Actually, since he's trying to return something, he should use
arg_present() (which really should be called by_reference() or
something). This doesn't check if the keyword is defined or note
(presumably you don't care), but just whether its value at the main
level can be altered:

if arg_present(b) then b = fltarr(10)

Arg_present() was added some time ago to solve just this type of problem
(which RSI did internally with IDL functions quite a bit).

JD
[Message index]
 
Read Message
Read Message
Previous Topic: keyword question
Next Topic: warping continents to magnetic coordinates

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

Current Time: Wed Oct 08 19:09:57 PDT 2025

Total time taken to generate the page: 0.00737 seconds