本文共 2839 字,大约阅读时间需要 9 分钟。
Syntax: -arg
value
Specifies a single command line option to be saved for later access via the function. The value string is saved. Multiple -arg
switches are allowed; the values are saved in the order specified. The -arg
option can be used to pass program-specific information from the command line to IDL programs.
Syntax: -args
value1 value2 ... valueN
Specifies one or more command line options to be saved for later access via the function. When IDL sees the -args
option, it takes any command-line arguments that follow it and saves them all. There can only be one -args
option on an IDL command line, and it is always the final option. The -args
switch can be used with the -arg
switch; if both switches are specified, occurrences of -arg
must come first, and the values specified by -args are saved following any values specified by -arg
.
The COMMAND_LINE_ARGS function returns strings supplied by the user when IDL was started with the -arg
or -args
command line options. If either of these options is specified at the command line when IDL is started, IDL saves them without examining their values or attaching any special meaning to them.
Note The shell performs its normal interpretation of wildcards and shell metacharacters before the values of the -arg or -args command line options are passed to IDL. |
Strings specified at the command line can be retrieved at any time within the IDL session via the COMMAND_LINE_ARGS function. This mechanism can be used to pass special application-defined values to a program written in the IDL language.
Result = COMMAND_LINE_ARGS( [, =variable] )
If any -arg
or -args
options were specified at the command line when IDL was started, COMMAND_LINE_ARGS returns a string array containing the specified values, one value per element. The values are returned in the order specified by the user on the command line. If no such options were specified, a NULL scalar string is returned.
Set this keyword equal to a named variable that will contain the number of retrieved arguments. If no arguments were specified, the variable will contain 0.
The COMMAND_LINE_ARGS
routine was introduced in IDL 6.2, allowing IDL programs to access command line args passed to IDL when starting it. For example, to pass command line arguments into the MYPROGRAM
routine, call IDL like below:
$ idl -e "myprogram" -args a b c
Then, in MYPROGRAM
, the command line arguments could be retrieved with:
args = command_line_args()
The args
string array would contain “a”, “b”, and “c”. To make it more convenient to launch IDL this way, you can create a script that calls IDL in the proper way, passing arguments of the script to arguments listed after the -args
in the IDL call. If you name the wrapper script myprogram
also, your calls would look like:
$ myprogram a b c
转载地址:http://opiqb.baihongyu.com/