<> <> <> <<>> <<>> DIRECTORY Commander USING [CommandProc, Register], Convert USING [RopeFromCard], Rope USING [Cat, Fetch, FromChar, Length, ROPE], FS USING [StreamOpen], IO USING [card, Close, PutF, rope, STREAM]; SparcPinNameConvert: CEDAR PROGRAM IMPORTS IO, Commander, Convert, Rope, FS = BEGIN ROPE: TYPE = Rope.ROPE; pGASideSize: CARD ~ 17; pGARows: CARD ~ 4; Location: PROC [x, y: CARD] RETURNS [location: ROPE] ~ { c: CHAR; SELECT x FROM -- SOME LETTERS ARE MISSING IN THE NUMBERING IN [1..8] => c _ x - 1 + 'A + 0; IN [9..13] => c _ x - 1 + 'A + 1; = 14 => c _ x - 1 + 'A + 2; = 15 => c _ x - 1 + 'A + 3; IN [16..17] => c _ x - 1 + 'A + 4; ENDCASE => ERROR; location _ Rope.Cat[Rope.FromChar[c], Convert.RopeFromCard[y]]; }; XYFromRope: PROC [location: ROPE] RETURNS [x, y: CARD] ~ { c: CHAR; SELECT Rope.Length[location] FROM -- verify the correct length = 2 => { y _ Rope.Fetch[location, 1] - '0; }; = 3 => { y _ (Rope.Fetch[location, 1] - '0) * 10 + Rope.Fetch[location, 2] - '0; }; ENDCASE => ERROR; c _ Rope.Fetch[location, 0]; -- Takes first character SELECT c FROM -- SOME LETTERS ARE MISSING IN THE NUMBERING IN ['A..'H] => x _ c - 'A + 1 - 0; IN ['J..'N] => x _ c - 'A + 1 - 1; = 'P => x _ c - 'A + 1 - 2; = 'R => x _ c - 'A + 1 - 3; IN ['T..'U] => x _ c - 'A + 1 - 4; ENDCASE => ERROR; }; SparcPinNameConvertProc: Commander.CommandProc = BEGIN i: CARD; x, y: CARD; out: IO.STREAM; <<>> out _ FS.StreamOpen["SparcPinNameConvert.tioga",$create]; i _ 1; FOR x IN [1..pGARows] DO FOR y IN [1..pGASideSize] DO IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]]; i _ i + 1; ENDLOOP; ENDLOOP; FOR x IN [pGARows+1..pGASideSize-pGARows] DO FOR y IN [1..pGARows] DO IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]]; i _ i + 1; ENDLOOP; FOR y IN [pGASideSize-pGARows+1..pGASideSize] DO IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]]; i _ i + 1; ENDLOOP; ENDLOOP; FOR x IN [pGASideSize-pGARows+1..pGASideSize] DO FOR y IN [1..pGASideSize] DO IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]]; i _ i + 1; ENDLOOP; ENDLOOP; IO.Close[out]; END; Commander.Register[ key: "SparcPinNameConvert", proc: SparcPinNameConvertProc]; END.