Procedures with variable/dynamic argument list?? [message #73106] |
Thu, 21 October 2010 18:49  |
SonicKenking
Messages: 51 Registered: October 2010
|
Member |
|
|
Is it possible in IDL to code a procedure using variable/dynamic
argument list?? i.e. the number of arguments is arbitrary and the
procedure is able to accept them all with some argument array?
Similar to the "va_list" in C or "*args" in Python.
The Print command in IDL is a good example too for accepting arbitrary
number of arguments and print them all. Unfortunately, the Print
command is not written in IDL, hence no sneak peek of the source code
~~
|
|
|
Re: Procedures with variable/dynamic argument list?? [message #89951 is a reply to message #73106] |
Thu, 08 January 2015 12:27  |
pgerakines
Messages: 1 Registered: January 2015
|
Junior Member |
|
|
It's not exactly what you're asking for, but recently I've discovered this is possible with the new LIST variable type.
You can pass a LIST variable to your procedure, where each element is one of the arguments in the "usual type" of procedure/function call. You can then determine the number of elements in the LIST that was passed using the list::count function method.
So you can call the procedure with any number of arguments, as long as you package them into a LIST first.
> myprocedure, LIST(x1,x2,x3,x4,x5,x6)
> myprocedure, LIST(x1,x2,x3)
where
PRO my_procedure, x
n = x.count()
x1 = x[0]
x2 = x[1]
; etc.
END
|
|
|