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

Home » Public Forums » archive » dealing with arguments
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: dealing with arguments [message #71263 is a reply to message #71119] Wed, 02 June 2010 15:50 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
pp writes:

> pro name, mode, s1=s1, s2=s2
> s2=n_elements(s2) ne 0 ? s2 : 10
> ...
> end
>
> Which you could then call as
>
> name, 2, s2=100
>
> It would make s2=10 if it is not provided (or is given an undefined
> variable).

An alternative, which is a bit more descriptive in
your programs, is SetDefaultValue:

pro name, mode, s1=s1, s2=s2

setdefaultvalue, s1, 5
setdefaultvalue, s2, 10
...

The default value is set (using pp's notation, basically)
only if the variable is undefined when the program is run.

You can find the program here:

http://www.dfanning.com/programs/setdefaultvalue.pro

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: dealing with arguments
Next Topic: trying to find land/water coverage maps for NA

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

Current Time: Tue Dec 02 09:01:17 PST 2025

Total time taken to generate the page: 1.84653 seconds