Re: Help needed on calling an IDL procedure from the Linux command line [message #45340 is a reply to message #45268] |
Sat, 27 August 2005 16:25  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
> So I was wondering: is it possible to pass input variables via a
> command line call? Can these be provided directly, or via an input
> file? I contacted David Fanning, and he suggested that this group would
> be a good source of information on this topic. Any help or information
> that you have on this would be greatly appreciated.
The new IDL 6.2 includes support for command line arguments. You can
specify command line arguments with either the -arg or -args options.
For example:
$ idl test.pro -quiet -args arg1 arg2 arg3
Notice that the file test.pro must be a batch file rather than a
procedure or function. If it's not a batch file, you will get the error
message about programs not being able to be compiled in single statement
mode. Here are the contents of a very simple test.pro:
args = command_line_args()
print, n_elements(args)
print, args
And here's what I get when running it:
$ idl test.pro -quiet -args arg1 arg2 arg3
3
arg1 arg2 arg3
Typically, I will keep the batch file pretty small and use it only parse
the command line arguments. I then call the procedure or function that
does the real work. I split things up this so that I can call my core
code either from the command line or from another routine. My batch
programs usually look something like:
args = command_line_args()
; check args and set input and keyword values
really_nifty_idl_code(input1, input2, keyword = keyword1)
-Mike
|
|
|