PROCEDURE getc(VAR ch: char); {$R-}{ * RANGE CHECKING OFF * } BEGIN xeof := false; IF NOT EOF(stdin) THEN READ(stdin,ch); IF EOF(stdin) THEN begin ch := ' '; xeof := true; end else if ch=chr(5) then { * end of file on the console? * } xeof := true; end; {$R+}{ * RANGE CHECKING ON * } PROCEDURE putc(c:CHAR); BEGIN if c=newline then writeln(stdout) else WRITE(stdout,c); {output the character} END; PROCEDURE puts(VAR LINE:MSTRING); var i:int; BEGIN for i:=1 to length(LINE) do putc( LINE[i] ); END; procedure gets(var inbuf:MSTRING); (* GLOBAL: newline: CHAR; xeof: BOOLEAN; SMAX = 255; stdin: TEXT; *) var ch: char; BEGIN setlength(inbuf,0); WHILE not eoln(stdin) and not xeof do begin getc(ch); If ORD(ch)>127 then ch := CHR( ORD(ch)-127 ); If length(inbuf) < SMAX then (* start accepting characters *) append(inbuf, ch) end; READLN(stdin); {+++ ignore the line boundary +++} append(inbuf,newline); end; cters *) append(inbuf, ch) end; READLN(stdin); {+++ ignore the line boundary