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 #50640 is a reply to message #50492] Thu, 05 October 2006 22:32 Go to previous message
Dominic Metzger is currently offline  Dominic Metzger
Messages: 30
Registered: August 2006
Member
Wow, I got you guys started on something here... thanks for your input.

So assuming that READ_PICT would also have some keyword parameters,
then I could use REF_EXTRA in the following way... correct?

pro READ_PICT_WRAPPER, Filename, Image, R, G, B, _REF_EXTRA=E
case (N_PARAMS()) of
5: READ_PICT, Filename, Image, R, G, B, _EXTRA=E
4: READ_PICT, Filename, Image, R, G, _EXTRA=E
3: READ_PICT, Filename, Image, R, _EXTRA=E
2: READ_PICT, Filename, Image, _EXTRA=E
else: message, "READ_PICT must have at least two parameters"

pro READ_PICT_WRAPPER, Filename, Image, R, G, B, _REF_EXTRA=E
IF N_Elements(B) EQ 0 THEN $
READ_PICT, Filename, Image, R, G, B, _EXTRA=E
ELSE...

For the second option: Could I build an array for { Filename, Image, R,
G, B} and pass it in?

best regards,

dominic

David Fanning wrote:
> 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: Fri Oct 10 14:55:13 PDT 2025

Total time taken to generate the page: 1.03079 seconds