MODULE copyprog; (*DEE 2020-05-02*) (* Uses the ISO/IEC 10514-1 standard library. *) FROM SIOResult IMPORT ReadResult, ReadResults; FROM STextIO IMPORT ReadChar, SkipLine, WriteChar, WriteLn; VAR ch: CHAR; BEGIN ReadChar(ch); WHILE ReadResult() # endOfInput DO IF ReadResult() # endOfLine THEN WriteChar(ch) ELSE SkipLine; WriteLn END; ReadChar(ch) END END copyprog. DEFINITION MODULE GetPut; (*DEE 2017-10-21/2022-08-20*) VAR Done: BOOLEAN; (* GetChar: get one character from standard input *) PROCEDURE GetChar (VAR c: CHAR): BOOLEAN; (* PutChar: put one character on standard output *) PROCEDURE PutChar (c: CHAR); END GetPut. IMPLEMENTATION MODULE GetPut; (*DEE 2017-10-21/2022-08-20*) IMPORT STextIO, SIOResult; FROM Chars IMPORT NEWLINE; PROCEDURE GetChar (VAR c: CHAR): BOOLEAN; VAR ch: CHAR; BEGIN STextIO.ReadChar(ch); IF SIOResult.ReadResult() = SIOResult.endOfInput THEN RETURN FALSE ELSIF SIOResult.ReadResult() = SIOResult.endOfLine THEN STextIO.SkipLine; c := NEWLINE; RETURN TRUE ELSE c := ch; RETURN TRUE END; END GetChar; PROCEDURE PutChar (c: CHAR); BEGIN IF (c = NEWLINE) THEN STextIO.WriteLn ELSE STextIO.WriteChar(c) END END PutChar; BEGIN Done := FALSE; END GetPut. MODULE copy; (*DEE 2013-12-11/2022-08-27*) (* Software Tools in Pascal, Exercise 1-1. *) FROM GetPut IMPORT GetChar, PutChar; (* copy: copy input to output *) PROCEDURE copy; VAR c: CHAR; BEGIN WHILE GetChar(c) # FALSE DO PutChar(c) END END copy; BEGIN (* Main program. *) copy END copy.