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

Home » Public Forums » archive » REBIN 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: rebin question [message #29877 is a reply to message #11091] Mon, 25 March 2002 14:07 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Mark Fardal" <fardal@coral.phys.uvic.ca> wrote in message
news:yj1zo0xta36.fsf@coral.phys.uvic.ca...
> hradilv.nospam@yahoo.com (Vince) writes:
>> Is it possible to define a function or procedure in IDL that can take
>> an arbitrary number of arguments...
>
> Sure. Something like this:
>
> function my_rebin, a, $
> arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
> ;continue to heart's content
>
> narg = n_params()-1
> command = 'result = round( rebin( float(a)'
> for i = 0, narg-1 do begin
> command = command + string(', arg',i,format='(a,i0)')
> endfor
> command = command + ') )'
> junk = execute(command)
> return, result
> end
>
> I imagine there are limits placed on this technique by the maximum
> number of arguments to an IDL procedure, or the maximum length of a
> string EXECUTE can handle.

The maximum number of arguments to an IDL procedure is far higher than
any sane programmer would want to use. The maximum length of an
EXECUTE'd string used to be a significant limitation in earlier
versions of IDL (I think it was 64, later 256) but in 5.4 or 5.5 it
was also increased to an effectively infinite value.

When writing wrapper procedures of this sort (which I do quite
often, for various reasons) I prefer to use this form

pro myfoo, p1, p2, ...
case n_params() of
0: foo
1: foo, p1
2: foo, p1, p2
...
endcase
end

I have gone as far as handling 15 positional parameters, but I don't
think I've ever used more than 4.

--
Mark Hadfield
m.hadfield@niwa.co.nz Ka puwaha et tai nei
http://katipo.niwa.co.nz/~hadfield Hoea tatou
National Institute for Water and Atmospheric Research (NIWA)
[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
Previous Topic: Re: A little handy date function
Next Topic: Want to get Array(48) instead of Array(1,48)

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

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

Total time taken to generate the page: 0.00515 seconds