Re: Creating procedure with arbitrary number of input parameters [message #78986] |
Sat, 14 January 2012 11:26 |
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 #78997 is a reply to message #78991] |
Thu, 12 January 2012 12:30  |
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  |
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  |
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
|
|
|