DEFINITION MODULE InOut; CONST EOL = 12C; VAR Done : BOOLEAN; termCH : CHAR; PROCEDURE OpenInput(defext: ARRAY OF CHAR); (* Request a file name from the standard input stream and open this file for reading. If the filename ends with a '.', append the "defext" extension. Done := "file was successfully opened". If open, subsequent input is read from this file. *) PROCEDURE OpenOutput(defext : ARRAY OF CHAR); (* Request a file name from the standard input stream and open this file for writing. If the filename ends with a '.', append the "defext" extension. Done := "file was successfully opened". If open, subsequent output is written to this file. *) PROCEDURE OpenInputFile(filename: ARRAY OF CHAR); (* Like OpenInput, but filename given as parameter *) PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR); (* Like OpenOutput, but filename given as parameter *) PROCEDURE CloseInput; (* Close input file. Subsequent input is read from the standard input stream. *) PROCEDURE CloseOutput; (* Close output file. Subsequent output is written to the standard output stream. *) PROCEDURE Read(VAR ch : CHAR); (* Read a character from the current input stream and leave it in "ch". Done := NOT "end of file". *) PROCEDURE ReadString(VAR s : ARRAY OF CHAR); (* Read a string from the current input stream and leave it in "s". A string is any sequence of characters not containing blanks or control characters; leading blanks are ignored. Input is terminated by any character <= " ". This character is assigned to termCH. DEL or BACKSPACE is used for backspacing when input from terminal. *) PROCEDURE ReadInt(VAR x : INTEGER); (* Read a string and convert it to INTEGER. Syntax: integer = ['+'|'-'] digit {digit}. Leading blanks are ignored. Done := "integer was read". *) PROCEDURE ReadCard(VAR x : CARDINAL); (* Read a string and convert it to CARDINAL. Syntax: cardinal = digit {digit}. Leading blanks are ignored. Done := "cardinal was read". *) PROCEDURE Write(ch : CHAR); (* Write character "ch" to the current output stream. *) PROCEDURE WriteLn; (* Terminate line. *) PROCEDURE WriteString(s : ARRAY OF CHAR); (* Write string "s" to the current output stream *) PROCEDURE WriteInt(x : INTEGER; n : CARDINAL); (* Write integer x with (at least) n characters on the current output stream. If n is greater that the number of digits needed, blanks are added preceding the number. *) PROCEDURE WriteCard(x, n : CARDINAL); (* Write cardinal x with (at least) n characters on the current output stream. If n is greater that the number of digits needed, blanks are added preceding the number. *) PROCEDURE WriteOct(x, n : CARDINAL); (* Write cardinal x as an octal number with (at least) n characters on the current output stream. If n is greater that the number of digits needed, blanks are added preceding the number. *) PROCEDURE WriteHex(x, n : CARDINAL); (* Write cardinal x as a hexadecimal number with (at least) n characters on the current output stream. If n is greater that the number of digits needed, blanks are added preceding the number. *) END InOut.