AmHerDictTest.mesa
Edited by: John Maxwell April 16, 1986 3:22:59 pm
DIRECTORY
AmHerDict,
AmHerDictRpcControl,
Commander,
IO,
Rope USING [Length, ROPE],
UserCredentials USING [Get];
AmHerDictTest: CEDAR PROGRAM
IMPORTS AmHerDictRpcControl, Commander, IO, Rope, UserCredentials
~ BEGIN
interface: REF AmHerDictRpcControl.InterfaceRecordObject ← NIL;
dictionary: ATOMNIL;
GetDefinition: PROC [cmd: Commander.Handle] RETURNS [result: REFNIL, msg: Rope.ROPENIL] ~ {
word: Rope.ROPE;
commandLineStream: IO.STREAMIO.RIS[cmd.commandLine];
word ← IO.GetTokenRope[commandLineStream !IO.EndOfStream => CONTINUE].token;
IF interface=NIL THEN interface ← AmHerDictRpcControl.ImportNewInterface[interfaceName: [instance: "DictServer"]];
IF dictionary = NIL THEN dictionary ← AmHerDictRpcControl.Dictionaries[interface, UserCredentials.Get[].name].first;
IF word.Length[] # 0 THEN result ← AmHerDictRpcControl.GetDefinition[interface, word, dictionary ! interface.LispError => {cmd.out.PutRope["error in remote server: "]; cmd.out.PutRope[error]; cmd.out.PutChar['\n]; CONTINUE}].definition;
IF result # NIL THEN {
cmd.out.PutRope[NARROW[result, Rope.ROPE]];
cmd.out.PutChar['\n];
RETURN[$Success]}
ELSE RETURN [$Failure];
};
Commander.Register[key: "Definition", proc: GetDefinition, doc: "retrieves definitions from the American Heritage Dictionary"];
END.