GetDefinition:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF ←
NIL, msg: Rope.
ROPE ←
NIL] ~ {
word: Rope.ROPE;
commandLineStream: IO.STREAM ← IO.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"];