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

Home » Public Forums » archive » Re: Creating procedure with arbitrary number of input parameters
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Creating procedure with arbitrary number of input parameters [message #78986] Sat, 14 January 2012 11:26
Russell[1] is currently offline  Russell[1]
Messages: 101
Registered: August 2011
Senior Member
It's ugly, but it's doable....

Presumably, you have some code that will call some other code which
has an unknown number of inputs (and possibly outputs), making it
impossible to elegantly write it ahead of time. However, the first
code must know what number of inputs and outputs that code 2 should
have, so why not just write code 2 in real-time. So store your code
as a string (or even read it from an ascii file) and write it out to
be compiled with "resolve_routine" and called by "call_procedure" or
"call_function". You could use "execute", but that'll be a mess if
you decide to use the IDL Virtual Machine.

Russell


On Jan 12, 2:34 pm, PMan <bloodysam.v...@gmail.com> wrote:
> I am trying to created a procedure with an arbitrary number of input
> parameters that will be determined at run time.  There does seem to be
> a mechanism to do this in IDL.  For example, in the STRING function:
>
> Syntax
> Result = STRING( Expression1, ..., Expressionn,  ....
>
> can handle N input parameters. However, I cannot find any documents or
> references showing how to implement this.
>
> Does any one here know how this can be achieved?
>
> Thank you for your attention.
Re: Creating procedure with arbitrary number of input parameters [message #78989 is a reply to message #78986] Fri, 13 January 2012 11:13 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jan 12, 5:36 pm, Michael Galloy <mgal...@gmail.com> wrote:
> It can be done in C as a DLM.

Also, using _extra/_ref_extra, possibly with scope_varfetch(),
depending on the case. See the help on extra arguments.
Re: Creating procedure with arbitrary number of input parameters [message #78990 is a reply to message #78989] Fri, 13 January 2012 10:30 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Often you don't need to use a CASE statement but can use SCOPE_VARFETCH in a loop to get values from the input parameters or put them into output parameters. For example, READCOL http://idlastro.gsfc.nasa.gov/ftp/pro/misc/readcol.pro accepts anywhere between 2 and 40 parameters without the need for any CASE statements. --Wayne
Re: Creating procedure with arbitrary number of input parameters [message #78991 is a reply to message #78990] Fri, 13 January 2012 09:48 Go to previous message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
How about passing your args as a structure, à la MPFIT ?

G
Re: Creating procedure with arbitrary number of input parameters [message #78997 is a reply to message #78991] Thu, 12 January 2012 12:30 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 1/12/12 12:58 PM, PMan wrote:
> On Jan 12, 2:36 pm, Michael Galloy<mgal...@gmail.com> wrote:
>> On 1/12/12 12:34 PM, PMan wrote:
>>
>>> I am trying to created a procedure with an arbitrary number of input
>>> parameters that will be determined at run time. There does seem to be
>>> a mechanism to do this in IDL. For example, in the STRING function:
>>
>>> Syntax
>>> Result = STRING( Expression1, ..., Expressionn, ....
>>
>>> can handle N input parameters. However, I cannot find any documents or
>>> references showing how to implement this.
>>
>>> Does any one here know how this can be achieved?
>>
>>> Thank you for your attention.
>>
>> It can be done in C as a DLM.
>>
>> Mike
>> --
>> Michael Galloywww.michaelgalloy.com
>> Modern IDL, A Guide to Learning IDL:http://modernidl.idldev.com
>> Research Mathematician
>> Tech-X Corporation
>
> Ah, I see. Time for plan B. Thank you for your quick answer.

Of course, you can fake this by making your routine have 10 arguments
(or whatever number you don't think the user will ever exceed) and a
CASE statement. Ugly, but gets the job done usually.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
Re: Creating procedure with arbitrary number of input parameters [message #79000 is a reply to message #78997] Thu, 12 January 2012 11:58 Go to previous message
PMan is currently offline  PMan
Messages: 61
Registered: January 2011
Member
On Jan 12, 2:36 pm, Michael Galloy <mgal...@gmail.com> wrote:
> On 1/12/12 12:34 PM, PMan wrote:
>
>> I am trying to created a procedure with an arbitrary number of input
>> parameters that will be determined at run time.  There does seem to be
>> a mechanism to do this in IDL.  For example, in the STRING function:
>
>> Syntax
>> Result = STRING( Expression1, ..., Expressionn,  ....
>
>> can handle N input parameters. However, I cannot find any documents or
>> references showing how to implement this.
>
>> Does any one here know how this can be achieved?
>
>> Thank you for your attention.
>
> It can be done in C as a DLM.
>
> Mike
> --
> Michael Galloywww.michaelgalloy.com
> Modern IDL, A Guide to Learning IDL:http://modernidl.idldev.com
> Research Mathematician
> Tech-X Corporation

Ah, I see. Time for plan B. Thank you for your quick answer.
Re: Creating procedure with arbitrary number of input parameters [message #79002 is a reply to message #79000] Thu, 12 January 2012 11:36 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 1/12/12 12:34 PM, PMan wrote:
> I am trying to created a procedure with an arbitrary number of input
> parameters that will be determined at run time. There does seem to be
> a mechanism to do this in IDL. For example, in the STRING function:
>
> Syntax
> Result = STRING( Expression1, ..., Expressionn, ....
>
> can handle N input parameters. However, I cannot find any documents or
> references showing how to implement this.
>
> Does any one here know how this can be achieved?
>
> Thank you for your attention.

It can be done in C as a DLM.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Multiple parameters for ZEROFCN
Next Topic: Multiple parameters for ZEROFCN

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

Current Time: Wed Oct 08 15:48:37 PDT 2025

Total time taken to generate the page: 0.00798 seconds