1 DEFINITION MODULE InOut;
3 Module: Wirth's Input/Output module
4 From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
5 Version: $Id: InOut.def,v 1.4 1994/06/24 12:48:45 ceriel Exp $
13 PROCEDURE OpenInput(defext: ARRAY OF CHAR);
14 (* Request a file name from the standard input stream and open
15 this file for reading.
16 If the filename ends with a '.', append the "defext" extension.
17 Done := "file was successfully opened".
18 If open, subsequent input is read from this file.
21 PROCEDURE OpenOutput(defext : ARRAY OF CHAR);
22 (* Request a file name from the standard input stream and open
23 this file for writing.
24 If the filename ends with a '.', append the "defext" extension.
25 Done := "file was successfully opened".
26 If open, subsequent output is written to this file.
27 Files left open at program termination are automatically closed.
30 PROCEDURE OpenInputFile(filename: ARRAY OF CHAR);
31 (* Like OpenInput, but filename given as parameter.
32 This procedure is not in Wirth's InOut.
35 PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR);
36 (* Like OpenOutput, but filename given as parameter.
37 This procedure is not in Wirth's InOut.
41 (* Close input file. Subsequent input is read from the standard input
45 PROCEDURE CloseOutput;
46 (* Close output file. Subsequent output is written to the standard
50 PROCEDURE Read(VAR ch : CHAR);
51 (* Read a character from the current input stream and leave it in "ch".
52 Done := NOT "end of file".
55 PROCEDURE ReadString(VAR s : ARRAY OF CHAR);
56 (* Read a string from the current input stream and leave it in "s".
57 A string is any sequence of characters not containing blanks or
58 control characters; leading blanks are ignored.
59 Input is terminated by any character <= " ".
60 This character is assigned to termCH.
61 DEL or BACKSPACE is used for backspacing when input from terminal.
64 PROCEDURE ReadInt(VAR x : INTEGER);
65 (* Read a string and convert it to INTEGER.
66 Syntax: integer = ['+'|'-'] digit {digit}.
67 Leading blanks are ignored.
68 Done := "integer was read".
71 PROCEDURE ReadCard(VAR x : CARDINAL);
72 (* Read a string and convert it to CARDINAL.
73 Syntax: cardinal = digit {digit}.
74 Leading blanks are ignored.
75 Done := "cardinal was read".
78 PROCEDURE Write(ch : CHAR);
79 (* Write character "ch" to the current output stream.
86 PROCEDURE WriteString(s : ARRAY OF CHAR);
87 (* Write string "s" to the current output stream
90 PROCEDURE WriteInt(x : INTEGER; n : CARDINAL);
91 (* Write integer x with (at least) n characters on the current output
92 stream. If n is greater that the number of digits needed,
93 blanks are added preceding the number.
96 PROCEDURE WriteCard(x, n : CARDINAL);
97 (* Write cardinal x with (at least) n characters on the current output
98 stream. If n is greater that the number of digits needed,
99 blanks are added preceding the number.
102 PROCEDURE WriteOct(x, n : CARDINAL);
103 (* Write cardinal x as an octal number with (at least) n characters
104 on the current output stream.
105 If n is greater that the number of digits needed,
106 blanks are added preceding the number.
109 PROCEDURE WriteHex(x, n : CARDINAL);
110 (* Write cardinal x as a hexadecimal number with (at least)
111 n characters on the current output stream.
112 If n is greater that the number of digits needed,
113 blanks are added preceding the number.