MumbleCommands.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
DIRECTORY Commander, CommanderOps, Convert, Rope, IO;
MumbleCommands: CEDAR PROGRAM
IMPORTS Commander, CommanderOps, Convert, Rope, IO
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
docMumbleCommand: ROPE ~ "function
args: args
switches: switches";
MumbleCommand: Commander.CommandProc ~ {
ENABLE Convert.Error => CommanderOps.Failed[cmd.procData.doc];
realArg: REAL ← 42.0;
intArg: INT ← 42;
fHead: LIST OF ROPE ~ LIST[NIL];
fLast: LIST OF ROPE ← fHead;
arg0: ROPE ← CommanderOps.NextArgument[cmd];
IF arg0 = NIL THEN CommanderOps.Failed[cmd.procData.doc];
FOR arg: ROPE ← arg0, CommanderOps.NextArgument[cmd] UNTIL arg = NIL DO
IF Rope.Match["-*", arg]
THEN {
FOR i: INT IN (0..Rope.Size[arg]) DO
SELECT Rope.Lower[Rope.Fetch[arg, i]] FROM
'r => realArg ← Convert.RealFromRope[CommanderOps.NextArgument[cmd]];
'i => intArg ← Convert.IntFromRope[CommanderOps.NextArgument[cmd]];
ENDCASE => CommanderOps.Failed[cmd.procData.doc];
ENDLOOP;
}
ELSE {
fLast ← fLast.rest ← LIST[arg];
};
ENDLOOP;
IO.PutF[cmd.out, "-r %g -i %g %g\n", [real[realArg]], [integer[intArg]], [refAny[fHead.rest]]];
};
Commander.Register["Mumble", MumbleCommand, docMumbleCommand];
END.