CmdTest.Mesa
Last Edited by: Spreitzer, May 6, 1985 9:29:04 pm PDT
Mike Spreitzer June 19, 1986 6:31:40 pm PDT
CmdTest:
CEDAR
PROGRAM
IMPORTS Commander, CommandTool, IO, List
={
ROPE: TYPE = Rope.ROPE;
regDir: ROPE ← CommandTool.CurrentWorkingDirectory[];
Answerback:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF
ANY ←
NIL, msg:
ROPE ←
NIL]
--Commander.CommandProc-- = {
s: IO.STREAM ← IO.RIS[cmd.commandLine];
result ← s.GetRefAny[];
msg ← s.GetLineRope[];
s.Close[];
};
ShowResult:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF
ANY ←
NIL, msg:
ROPE ←
NIL]
--Commander.CommandProc-- = {
result ← List.Assoc[$Result, cmd.propertyList];
msg ← IO.PutFR["previous Result = %g", IO.refAny[result]];
};
ResultOf:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF
ANY ←
NIL, msg:
ROPE ←
NIL]
--Commander.CommandProc-- = {
result ← CommandTool.DoCommand[cmd.commandLine, cmd];
msg ← IO.PutFR["Result = %g", IO.refAny[result]];
};
Start:
PROC = {
Commander.Register[key: "Answerback", proc: Answerback, doc: "reads result and msg from command line (uninterpreted)", interpreted: FALSE];
Commander.Register[key: "ShowResult", proc: ShowResult, doc: "tells Result of previous command"];
Commander.Register[key: "ResultOf", proc: ResultOf, doc: "executes command and tells Result", interpreted: FALSE];
};
Start[];
}.