DIRECTORY Commander USING [CommandProc, Register], IO USING [PutF1, PutRope, rope, STREAM], Rope USING [Concat, Equal, Fetch, Find, FromChar, Length, ROPE, Substr], SystemNames USING [UserName]; ReverseName: CEDAR PROGRAM IMPORTS Commander, IO, Rope, SystemNames ~ BEGIN --(note 1.3) ROPE: TYPE = Rope.ROPE; --(note 1.4) ReverseName: Commander.CommandProc ~ { --(note 1.5) userName: ROPE ¬ SystemNames.UserName[]; --(note 1.6) out: IO.STREAM ¬ cmd.out; -- cmd is an arg to ReverseName. backwordsName: ROPE ¬ NIL; dotPos: INT = userName.Find["."]; --(note 1.7) IF dotPos # -1 THEN userName ¬ Rope.Substr[userName, 0, dotPos]; IF Rope.Equal[s1: userName, s2: "Weiser", case: FALSE] THEN IO.PutRope[out, "Hi, Mark!\n"]; FOR i: INT DECREASING IN [0..Rope.Length[userName]) DO backwordsName ¬ Rope.Concat[backwordsName, Rope.FromChar[Rope.Fetch[userName, i]]] ENDLOOP; IO.PutF1[out, "Your user name backwards is: %g.\n", IO.rope[backwordsName]]; --(Note 1.9) }; --(note 1.16) Commander.Register[key: "ReverseName", proc: ReverseName, doc: "Reverses your user name"]; END. l ReverseName.mesa --(note 1.1) Copyright Σ 1990, 1992 by Xerox Corporation. All rights reserved. Brian Oki, May 14, 1990 10:27 am PDT Christian Jacobi, May 14, 1992 2:22 pm PDT [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] Reverses the user's login name and prints it out in the CommandTool window. Remove anything after the period in user name, e.g., ".PA", and check for the name Weiser. Now reverse the name and concatenate them in reverse order. --[1.1] (note 1.8) Start code registers a ReverseName command, which must be invoked for this program to do anything: Κϋ•NewlineDelimiter –(cedarcode) style™šœ Οa ™+Jšœ Οeœ7™BJ™$J™*J™—codešΟk ˜ Kšœ Ÿœ˜(KšŸœŸœŸœ˜(KšœŸœ0Ÿœ ˜HKšœ Ÿœ ˜K˜—šΟn œŸœŸ˜KšŸœ Ÿœœ˜+—šŸ Πac ˜K˜—Kš ŸœŸœŸœ Οc‘ œ˜CJ™š  œ$‘ ˜9JšΠckH™HJ™KšœK™KKšœ Ÿœ#‘ œ˜RKšœŸœŸœ ’ Ρaci˜;KšœŸœŸœ˜KšœZ™ZKšœŸœ!‘ œ"˜XšŸœ Ÿ˜K˜,—šŸœ.ŸœŸ˜;KšŸœ˜—Kšœ;™;š ŸœŸœŸ œŸœŸ˜6Kš™K˜RKšŸœ˜—KšŸœ2Ÿœ’‘ ˜YKšœ˜K˜—Kšœb™bK˜Kšœ‘ ˜ šœZ˜ZK˜—KšŸœœ˜—…—€