| 1 |
(* Library module defined by the International Standard |
| 2 |
Information technology - programming languages |
| 3 |
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language. |
| 4 |
|
| 5 |
Copyright ISO/IEC (International Organization for Standardization |
| 6 |
and International Electrotechnical Commission) 1996-2021. |
| 7 |
|
| 8 |
It may be freely copied for the purpose of implementation (see page |
| 9 |
707 of the Information technology - Programming languages Part 1: |
| 10 |
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *) |
| 11 |
|
| 12 |
DEFINITION MODULE TextIO; |
| 13 |
|
| 14 |
(* Input and output of character and string types over |
| 15 |
specified channels. The read result is of the type |
| 16 |
IOConsts.ReadResults. |
| 17 |
*) |
| 18 |
|
| 19 |
IMPORT IOChan; |
| 20 |
|
| 21 |
(* The following procedures do not read past line marks *) |
| 22 |
|
| 23 |
PROCEDURE ReadChar (cid: IOChan.ChanId; VAR ch: CHAR); |
| 24 |
(* If possible, removes a character from the input stream |
| 25 |
cid and assigns the corresponding value to ch. The |
| 26 |
read result is set to the value allRight, endOfLine, or |
| 27 |
endOfInput. |
| 28 |
*) |
| 29 |
|
| 30 |
PROCEDURE ReadRestLine (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR); |
| 31 |
(* Removes any remaining characters from the input stream |
| 32 |
cid before the next line mark, copying to s as many as |
| 33 |
can be accommodated as a string value. The read result is |
| 34 |
set to the value allRight, outOfRange, endOfLine, or |
| 35 |
endOfInput. |
| 36 |
*) |
| 37 |
|
| 38 |
PROCEDURE ReadString (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR); |
| 39 |
(* Removes only those characters from the input stream cid |
| 40 |
before the next line mark that can be accommodated in s |
| 41 |
as a string value, and copies them to s. The read result |
| 42 |
is set to the value allRight, endOfLine, or endOfInput. |
| 43 |
*) |
| 44 |
|
| 45 |
PROCEDURE ReadToken (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR); |
| 46 |
(* Skips leading spaces, and then removes characters from |
| 47 |
the input stream cid before the next space or line mark, |
| 48 |
copying to s as many as can be accommodated as a string |
| 49 |
value. The read result is set to the value allRight, |
| 50 |
outOfRange, endOfLine, or endOfInput. |
| 51 |
*) |
| 52 |
|
| 53 |
(* The following procedure reads past the next line mark *) |
| 54 |
|
| 55 |
PROCEDURE SkipLine (cid: IOChan.ChanId); |
| 56 |
(* Removes successive items from the input stream cid up |
| 57 |
to and including the next line mark, or until the end |
| 58 |
of input is reached. The read result is set to the |
| 59 |
value allRight, or endOfInput. |
| 60 |
*) |
| 61 |
|
| 62 |
(* Output procedures *) |
| 63 |
|
| 64 |
PROCEDURE WriteChar (cid: IOChan.ChanId; ch: CHAR); |
| 65 |
(* Writes the value of ch to the output stream cid. *) |
| 66 |
|
| 67 |
PROCEDURE WriteLn (cid: IOChan.ChanId); |
| 68 |
(* Writes a line mark to the output stream cid. *) |
| 69 |
|
| 70 |
PROCEDURE WriteString (cid: IOChan.ChanId; s: ARRAY OF CHAR); |
| 71 |
(* Writes the string value in s to the output stream cid. *) |
| 72 |
|
| 73 |
END TextIO. |
| 74 |
|