Go
to the first, previous,
next, last section, table
of contents.
The IO interface
includes the most common I/O routines on readers and writers. Reader and
writer parameters for IO procedures may be omitted; If the reader parameter
is omitted, Stdio.stdin is used; if the writer parameter is omitted,
Stdio.stdout is used.
The following routines send characters to a writer. They flush the output
before returning, so they are not recommended for use with large files.
For information on more efficient writer routines, see section Wr
Interface. To output numbers, these routines use procedures in the
Fmt interface (see section Fmt Interface).
- PROCEDURE Put(txt: TEXT; wr: Wr.T := NIL);
- Output "txt" to "wr" and flush "wr".
- PROCEDURE PutInt(n: INTEGER; wr: Wr.T := NIL);
- Output "Fmt.Int(n)" to "wr" and flush "wr".
- PROCEDURE PutReal(r: REAL; wr: Wr.T := NIL);
- Output "Fmt.Real(r)" to "wr" and flush "wr".
The following routines are used to get information from a reader. The
exception "Error" is raised whenever a "Get" procedure
encounters syntactically invalid input, including unexpected end-of-file.
Routines in the Lex interface are used to read numbers (see section Lex
Interface).
- PROCEDURE EOF(rd: Rd.T := NIL): BOOLEAN;
- Return "TRUE" iff "rd" is at end-of-file.
- PROCEDURE GetLine(rd: Rd.T := NIL): TEXT RAISES {Error};
- Read a line of text from "rd" and return it. A line of text
is either zero or more characters terminated by a line break, or one or
more characters terminated by an end-of-file. In the former case, "GetLine"
consumes the line break but does not include it in the returned value.
- PROCEDURE GetChar(rd: Rd.T := NIL): CHAR RAISES {Error};
- Read the next character from "rd" and return it.
- PROCEDURE GetInt(rd: Rd.T := NIL): INTEGER RAISES {Error};
- Read a decimal numeral from "rd" using "Lex.Int"
and return its value.
- PROCEDURE GetReal(rd: Rd.T := NIL): REAL RAISES {Error};
- Read a real number from "rd" using "Lex.Real" and
return its value.
- PROCEDURE OpenRead(f: TEXT): Rd.T;
- Open the file name "f" for reading and return a reader on
its contents. If the file doesn't exist or is not readable, return "NIL".
- PROCEDURE OpenWrite(f: TEXT): Wr.T;
- Open the file named "f" for writing and return a writer on
its contents. If the file exists it will be erased. If the file does not
exist it will be created. If the process does not have the authority to
modify or create the file, return "NIL".
Go to the first, previous,
next, last section, table
of contents.