<> <> <<>> 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: ATOM _ NIL; 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"]; END.