DIRECTORY Commander, Rope; Args: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; Arg: TYPE ~ RECORD [ ok: BOOL ¬ FALSE, bool: BOOL ¬ FALSE, int: INT ¬ 0, real: REAL ¬ 0.0, rope: ROPE ¬ NIL]; NArgs: PROC [cmd: Commander.Handle] RETURNS [INTEGER]; GetRope: PROC [cmd: Commander.Handle, nArg: INTEGER ¬ 0] RETURNS [ROPE]; ArgRope: PROC [cmd: Commander.Handle, nArg: INTEGER ¬ 0] RETURNS [Arg]; ArgReal: PROC [cmd: Commander.Handle, nArg: INTEGER ¬ 0] RETURNS [Arg]; ArgInt: PROC [cmd: Commander.Handle, nArg: INTEGER ¬ 0] RETURNS [Arg]; ArgIntDef: PROC [cmd: Commander.Handle, nArg: INTEGER ¬ 0, defVal: INT] RETURNS [Arg]; ArgIntRange: PROC [cmd: Commander.Handle, n, min, max: INT] RETURNS [Arg]; Error: ERROR [reason: ROPE]; 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]; 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]; END. b Args.mesa Copyright Σ 1985, 1991 by Xerox Corporation. All rights reserved. Bloomenthal, November 25, 1987 1:43:20 pm PST Number of command line arguments (does not count argv[0]). Return argument nArg as a rope. Return rope of argument nArg as an Arg. Return real of argument nArg Return integer of argument nArg Return integer of argument nArg if it exists, else return the default value. arg.ok is true iff argument exists, is integer, and within specified range. 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; As ArgsGet except the input is provided by a rope. Κ¦•NewlineDelimiter –(cedarcode) style™codešœ ™ Kšœ Οeœ6™BK™-K™—KšΟk œ˜K™KšΠblœžœž ˜Kšœž˜˜Kšžœžœžœ˜K˜šœžœžœ˜Kšœžœžœ˜Kšœžœžœ˜Kšœžœ˜ Kšœžœ˜Kšœžœžœ˜—K˜šΟnœžœžœžœ˜6J™:—K˜š  œžœžœžœžœ˜HJšœ™J™—š œžœžœžœ˜GJ™'—K˜š œžœžœžœ˜GJ™J™—š œžœžœžœ˜FJ™—K˜š   œžœžœžœžœ˜VJ™L—K˜š  œžœ&žœžœ˜JJ™K—K˜š œžœ žœ˜K˜—š  œžœ!žœžœžœ˜PKšžœK˜RJ™JšœZ™ZJšœG™GJ™JšœS™SJšœB™BJ™šœ"™"J™0J™0J™D—J™šœ&™&J™$J™ J™"—J™šœ™J™RJ™PJ™=—J™J™\J™]J™XJ™9—™šœ™Jšœ™Jšœ7™7J™J™ZJ™[J™\™XJ™™Jšžœžœ ™0Jšœ,žœ™1—J™™Jšžœžœ ™0J™0—J™™Jšžœžœ™0J™—J™™Jšžœ%™)Jšœ=žœ™BJ™——šœE™EJ™™ Jšžœžœ™0Jšœžœ™—J™™Jšžœ%™*—J™™Jšžœžœ™0Jšœ™—J™™Jšžœžœ ™0Jšœ,žœ™1J™————š  œžœžœžœžœ˜HKšžœK˜RJ™2—J™—Kšžœ˜—…—(0