Head.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Weiser, November 25, 1991 11:23 pm PST
DIRECTORY Commander, Rope, IO;
Head: CEDAR PROGRAM
IMPORTS Commander, IO
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
Head: Commander.CommandProc ~ {
s: IO.STREAM = IO.RIS[cmd.commandLine];
N: CARD;
N ¬ IO.GetCard[s ! IO.Error, IO.EndOfStream => { N ¬ 10; CONTINUE} ];
FOR linenum: CARD IN (1..N) DO
ENABLE IO.Error, IO.EndOfStream => { GOTO finishup };
IO.Put[cmd.out,IO.rope[IO.GetLineRope[cmd.in]], IO.rope["\n"]];
ENDLOOP;
EXITS
finishup => RETURN;
};
Commander.Register["Head", Head, "filter out the first N lines of input.
Prototype: Head [N]"];
END.