ListVectors.mesa
Don Curry April 2, 1987 10:31:12 am PST
DIRECTORY Convert, FS, IFUPublic, IO, Rope;
ListVectors: CEDAR PROGRAM
IMPORTS Convert, FS, IO, Rope =
BEGIN
II: TYPE = IFUPublic.II;
ListVectors.ListVector["DDQuickTest.ifuVectorsPre"];
ListVector: PROC[file: IO.ROPE] = {
root: IO.ROPE  ← file.Substr[0, file.Index[0, "."]];
in:  IO.STREAM ← FS.StreamOpen[file];
out: IO.STREAM ← FS.StreamOpen[root.Cat[".list"], $create];
FOR line: INT ← 1, line+1 DO
IF (line-1) MOD 4 = 0 THEN out.PutF["--%12g\n", IO.int[(line-1)/4]];
out.PutF["%4g ", IO.int[line]];
FOR ii: II IN II DO
item: IO.ROPE ← in.GetTokenRope[! IO.EndOfStream => GOTO Exit].token;
IF ~ item.Equal["agg"] THEN ERROR;
item ← in.GetTokenRope[].token;
SELECT item.Fetch[] FROM 'f, 'e, 'n => out.PutRope[item]; ENDCASE => ERROR;
item ← in.GetTokenRope[].token;
SELECT item.Fetch[] FROM
'F, 'T  => out.PutF["%g ", IO.rope[item]];
IN ['0..'9] => out.PutF[ format[ii], IO.card[Convert.CardFromRope[item]]];
ENDCASE => ERROR;
REPEAT Exit => EXIT ENDLOOP;
out.PutChar[IO.CR];
ENDLOOP;
out.PutChar[IO.CR];
in.Close[];
out.Close[]};
format: ARRAY II OF Rope.ROPEALL[NIL];
format[IPData   ] ← "%8x ";
format[KBus    ] ← "%8x ";
format[DPCmd   ] ← "%2x ";
format[DPFault   ] ← "%1x ";
format[EUAluOp  ] ← "%1x ";
format[EUCondSel  ] ← "%1x ";
END.