ArgIntRange:
PROC [cmd: Commander.Handle, n, min, max:
INT]
RETURNS [Arg];
arg.ok is true iff argument exists, is integer, and within specified range.
ArgsGet:
PROC [cmd: Commander.Handle, format:
ROPE, caseSensitive:
BOOL ¬
FALSE]
RETURNS [Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg];
ArgsGet returns twelve args; each return arg has a boolean, integer, real, and rope field.
If any argument conversions are performed incorrectly, Error is raised.
format specifies the conversions to occur when parsing the commander argument list.
format syntax consists of a type delimiter and argument specifier.
Type delimiters within format are:
[ any following argument symbols are optional
% any following argument symbols are required
- any following arguments are required only if a key is specified
Argument specifiers within format are:
i an integer argument is expected
r a real argument is expected
s a string argument is expected
format examples:
"-pVal%i" if "-pVal" is an argument, an integer is expected to follow immediately.
"-f%b" if "-f" is an argument, the boolean field of its return Arg is set true.
"%iir" two integers and one real are expected as arguments.
A hyphenated type delimiter uniquely identifies itself and is allowed to appear in any order
within the argument list. Because of this, the argument list is scanned first for hyphenated
type delimiters and their arguments. A second scan is performed in which non-hyphenated
type delimiters are matched with the remaining arguments.
Conversion examples:
arg1, arg2, arg3, arg4: Arg;
[arg1, arg2, arg3, arg4] ← ArgsGet[cmd, "%is-x%r-q%b"];
First, the commander argument list is searched for a "-x." If found, a real should be the
next commander argument and arg3.int is set equal to it. Te argument list is next searched
for a "-q;" if found arg4.bool is set true. After this, an integer argument must remain and
is used to set arg1.int, and a string argument must remain and is used to set arg2.rope.
Program 3 name -q
TRUE: arg1.ok, arg2.ok, arg4.ok; FALSE: arg3.ok;
arg1.int = 3; arg2.rope = name; arg4.bool = TRUE.
Program -x 2.4 3 name
TRUE: arg1.ok, arg2.ok, arg3.ok; FALSE: arg4.ok;
arg1.int = 3; arg2.rope = name; arg3.real = 2.4.
Program 3 name
TRUE: arg1.ok, arg2.ok; FALSE: arg3.ok, arg4.ok;
arg1.int = 3; arg2.rope = name.
Program -q 3 -x 2.4 name
TRUE: arg1.ok, arg2.ok, arg3.ok, arg4.ok;
arg1.int = 3; arg2.rope = name; arg3.real = 2.4; arg4.bool = TRUE.
The following inputs all produce improper conversion and raise Error:
Program 3 -q
TRUE: arg1.ok, arg4.ok; FALSE: arg2.ok, arg3.ok;
arg1.int = 3; arg4.bool = TRUE.
Program -x name
FALSE: arg1.ok, arg2.ok, arg3.ok, arg4.ok.
Program -x 1 3 name
FALSE: arg3.ok, arg4.ok; TRUE: arg1.ok, arg2.ok;
arg1.int = 3; arg2.rope = name.
Program 3 name -q 2.4
TRUE: arg1.ok, arg2.ok, arg4.ok; FALSE: arg3.ok;
arg1.int = 3; arg2.rope = name; arg4.bool = TRUE;
ArgsGetFromRope:
PROC [input, format:
ROPE, caseSensitive:
BOOL ¬
FALSE]
RETURNS [Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg];
As ArgsGet except the input is provided by a rope.