Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / InOut.def
1 DEFINITION MODULE InOut;
2 (*
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 $
6 *)
7
8         CONST   EOL = 12C;
9
10         VAR     Done : BOOLEAN;
11                 termCH : CHAR;
12
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.
19         *)
20
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.
28         *)
29
30         PROCEDURE OpenInputFile(filename: ARRAY OF CHAR);
31         (* Like OpenInput, but filename given as parameter.
32            This procedure is not in Wirth's InOut.
33         *)
34
35         PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR);
36         (* Like OpenOutput, but filename given as parameter.
37            This procedure is not in Wirth's InOut.
38         *)
39
40         PROCEDURE CloseInput;
41         (* Close input file. Subsequent input is read from the standard input
42            stream.
43         *)
44
45         PROCEDURE CloseOutput;
46         (* Close output file. Subsequent output is written to the standard
47            output stream.
48         *)
49
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".
53         *)
54
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.
62         *)
63
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".
69         *)
70
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".
76         *)
77
78         PROCEDURE Write(ch : CHAR);
79         (* Write character "ch" to the current output stream.
80         *)
81
82         PROCEDURE WriteLn;
83         (* Terminate line.
84         *)
85
86         PROCEDURE WriteString(s : ARRAY OF CHAR);
87         (* Write string "s" to the current output stream
88         *)
89
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.
94         *)
95
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.
100         *)
101
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.
107         *)
108
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.
114         *)
115
116 END InOut.