DIRECTORY
Commander USING [CommandProc, Register],
IO, FS,
Rope USING [ROPE];
MakeTT: CEDAR PROGRAM    
IMPORTS Commander, IO, FS = BEGIN
Test: Commander.CommandProc = BEGIN
ins, outs, pterms: NAT;
outFile: Rope.ROPE;
outStream: IO.STREAM;
cmd.out.PutF["Name of output file? "];
outFile ← cmd.in.GetLineRope[];
outStream ← FS.StreamOpen[outFile, $create];
cmd.out.PutF["How many inputs? "];
ins ← cmd.in.GetInt[];
cmd.out.PutF["How many outputs? "];
outs ← cmd.in.GetInt[];
cmd.out.PutF["How many product terms? "];
pterms ← cmd.in.GetInt[];
FOR pterm: NAT IN [1 .. pterms) DO
val: INT ← pterm;
FOR in: NAT IN [1 .. ins) DO
IF val MOD 2 = 1 THEN outStream.PutF["1"] ELSE outStream.PutF["0"];
val ← val / 2;
ENDLOOP;
outStream.PutF[" | "];
val ← pterms;
FOR out: NAT IN [1 .. outs) DO
IF val MOD 2 = 1 THEN outStream.PutF["1"] ELSE outStream.PutF["0"];
val ← val / 2;
ENDLOOP;
outStream.PutF["\n"];
ENDLOOP;
IO.Close[outStream];
cmd.out.PutF["Done.\n"];
END;
Commander.Register[key: "MakeTT", proc: Test, doc: "Make a truth table"];
END.