|
|||||||||
|
|||||||||
Related Concepts | |||||||||
built-in variable | #args |
Purpose
A built-in shelf containing the names entered on the command line of an OmniMark program. The command line used to run an OmniMark program consists of three different kinds of tokens:
OmniMark reserves all tokens starting with -
(a hyphen) for use as predefined compiler, virtual machine, or program option. Any other token, or a token starting with --
(two hyphens), is treated as a command-line name.
The #args
shelf contains only the command-line arguments, not the compiler, VM, or program options.
You can use command-line arguments for any purpose you like in your program.
Note that #main-input
treats all the command-line arguments as input file names. If you use #main-input
in your program, it will attempt to open and read each named file in turn. OmniMark will create a throw to #external-exception if any of the files cannot be opened.
If you use #args
for other purposes than to name input files, you should avoid using #main-input
.
Here are two different ways to use the command line to establish input and output files for your program --
Command line: omnimark -s myprog.xom input.txt -of output.txt
process submit #main-input
Command line: omnimark -s myprog.xom input.txt output.txt
process local stream out open out as file #args[2] using output as out submit file #args[1]
Note that there is a difference between submitting #main-input
and the following code:
process repeat over #args submit #args again
Submitting #main-input causes all named files to be submitted as a single source. File boundaries are ignored in pattern matching. Repeating over #args and submitting each in turn, however, creates a distinct submit for each file. Pattern matching cannot occur across file boundaries.
Note that how text on the command line is broken up into tokens is operating system specific. Thus one operating system may recognize a quoted string as a single token, and another may recognize it as a sequence of tokens delimited by spaces. In other words, the following command line:
omnimark -s myprog.xom "Mary had a little lamb."could, under one operating system, yield a
#args
with a single item Mary had a little lamb
, while, under another operating system, it might yield a #args
with five items: "Mary
, had
, a
, little
, and lamb
.
#command-line-names is a deprecated synonym for #args
Related Concepts Command-line options Command-line syntax |
---- |