CmdTestDoc.tioga
Mike Spreitzer, June 19, 1986 6:38:09 pm PDT
CmdTest
CEDAR 6.1 — FOR INTERNAL XEROX USE ONLY
CmdTest
Mike Spreitzer
© Copyright 1986 Xerox Corporation. All rights reserved.
Abstract: Provides some commands useful for debugging the return values of other commands, and for debugging what happens to those returned values.
Created by: Mike Spreitzer
Maintained by: Mike Spreitzer <Spreitzer.pa>
Keywords: Command Tool, Command, CommandProc, Result, Message, Command result, Command message, Debug
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Introduction
In the command tool, a command is implemented by a Commander.CommandProc, whose type is:
CommandProc: TYPE = PROC [cmd: Handle] RETURNS [result: REFNIL, msg: ROPENIL];
Note that such procedures return something: result and msg. Some commands return nothing interesting, and some commands do return something interesting. There is little documentation about what happens to these return values. This package provides some commands that are helpful in debugging two things: what does a particular CommandProc return, and what happens with those returned values?
2. Commands
name Answerback:
syntax
Answerback result message
description
This is an easy way to produce a controlled result and msg. Does an IO.GetRefAny to read a result from the command line; the rest of the command line is the msg.
This command is uninterpreted --- no automatic substitution or other processing of the arguments is done.
examples

%
Answerback Failure you lose!
you lose!
% Answerback x "this is a test"
"this is a test"
%
What happens to the msg? It gets printed --- whether or not the result is $Failure.
name ShowResult:
syntax
ShowResult
description
Oh shit --- I wonder what that last command returned as its result? Use ShowResult.
examples

% Answerback (this "is a" TEST 4.7 TRUE 5)
% ShowResult
previous Result = ^LIST[$this, "is a", $TEST, ^4.7, ^TRUE, ^5]
% glozzle
[[glozzle not found]]
% ShowResult
previous Result = ^LIST[$this, "is a", $TEST, ^4.7, ^TRUE, ^5]
%
It's true --- a result can be any REF ANY. This also shows that an unrecognized command has no effect on the $Result property (which is where the result of the previous command is stored) --- contrary to what you might expect.
warnings
If an invocation of ShowResult is the first invocation of CmdTest, and thus the .load file for it has to be run, the result of the previous command will be lost because it is overwritten by the result of running the .load file.
name ResultOf:
syntax
ResultOf command
description
Executes the rest of the command line as a command, and prints the result.
This command is uninterpreted. Of course, that doesn't prevent the command it executes from being interpreted.
examples

% ResultOf Answerback (this "is a" TEST 4.7 TRUE 5) this is the msg
% Answerback (this "is a" TEST 4.7 TRUE 5) this is the msg
this is the msg
Result = ^LIST[$this, "is a", $TEST, ^4.7, ^TRUE, ^5]
% ResultOf Fail
% Fail
This Command Always Fails
Result = $Failure
% Answerback hi
% ResultOf glozzle
% glozzle
[[glozzle not found]]
Result = $hi
%