ELSE {
ENABLE IO.EndOfStream => GOTO EOF;
in:
IO.
STREAM ¬
FS.StreamOpen[args[0] ! FS.Error => {err ¬ error.explanation; GOTO Bad}];
colorFlag: CARDINAL ¬ IO.GetByte[in];
xOrigin: CARDINAL ¬ Basics.Card16FromH[IO.GetHWord[in]];
yOrigin: CARDINAL ¬ Basics.Card16FromH[IO.GetHWord[in]];
w: CARDINAL ¬ Basics.Card16FromH[IO.GetHWord[in]];
h: CARDINAL ¬ Basics.Card16FromH[IO.GetHWord[in]];
IO.PutF1[cmd.out, "Color flag: %g\n", IO.card[colorFlag]];
IO.PutF1[cmd.out, "xOrigin: %g\n", IO.card[xOrigin]];
IO.PutF1[cmd.out, "yOrigin: %g\n", IO.card[yOrigin]];
IO.PutF1[cmd.out, "width: %g\n", IO.card[w]];
IO.PutF1[cmd.out, "height: %g\n", IO.card[h]];
FOR y:
NAT
IN [yOrigin..yOrigin+h)
DO
IO.PutF1[cmd.out, "y = %g\n", IO.card[y]];
IF colorFlag = 0
THEN {
x: NAT ¬ 0;
WHILE x < w
DO
run: CARDINAL ¬ IO.GetByte[in];
val: CARDINAL ¬ IO.GetByte[in];
IO.PutF[cmd.out, "%g of %g\n", IO.card[run], IO.card[val]];
x ¬ x+run;
ENDLOOP;
}
ELSE {
x: NAT ¬ 0;
WHILE x < w
DO
run: CARDINAL ¬ IO.GetByte[in];
rgb: CtBasic.RGB ¬ [IO.GetByte[in], IO.GetByte[in], IO.GetByte[in]];
IO.PutFL[cmd.out, "%g of %g, %g, %g\n",
LIST[IO.card[run], IO.card[rgb.r], IO.card[rgb.g], IO.card[rgb.b]]];
x ¬ x+run;
ENDLOOP;
};
ENDLOOP;
EXITS
EOF => IO.PutRope[cmd.out, "Premature EndOfFile\n"];
Bad => RETURN[error: err];
};