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

Home » Public Forums » archive » Re: wrapper functions
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: wrapper functions [message #50492] Thu, 05 October 2006 20:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth P. Bowman writes:

> I find that N_PARAMS() with SWITCH is very handy for setting defaults in
> procedures where optional positional parameters make sense.
>
> PRO BLAH, A, B, C
>
> SWITCH N_PARAMS() OF
> 0 : A = ...
> 1 : B = ...
> 2 : C = ...
> ENDSWITCH

In thinking about it, I guess I use N_ELEMENTS for
all my parameters because I can throw better errors
since I know *exactly* which parameter is missing:

IF N_Elements(foo) EQ 0 THEN $
Message, 'Argument FOO must be a 2D array.'

I can also trap the error of the user calling my
routine with an undefined variable, rather than with
a real variable. This happens more often than you would
think in IDL programming courses. N_PARAMS, of course,
can't tell you much of anything about the parameter.

Cheers,

David

P.S. And don't even get me started on the mostly
mis-used KEYWORD_SET. I see that function misused
almost constantly in IDL programs to perform the
function of N_ELEMENTS. Folks, it DOESN'T!! :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[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
Previous Topic: Re: executing a string in VM without using 'EXECUTE'
Next Topic: reading .mat files in IDL

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

Current Time: Wed Oct 08 15:10:49 PDT 2025

Total time taken to generate the page: 0.00688 seconds