reada
From the SETL Wiki
| reada | |
|---|---|
| Category | I/O |
| Syntax | function |
| Compatibility | |
| CIMS SETL | yes |
| SETL-S | yes |
| SETL2 | yes |
| GNU SETL | yes |
Contents |
Purpose
Parse SETL values from a file.
Synopsis
reada(file, var1, var2 ... )
Description
Read a string representation of o SETL value from a file (as written to the file by printa.)
In CIMS SETL and SETL-S, file must be the filename of a previously-opened file.
In SETL2, file must be a handle to a previously-opened file.
In GNU SETL, file may be a file descriptor or filename. If a filename is given which is not already open, it is automatically opened for input.
Any leading spaces in the input are skipped, and parsing always starts from the beginning of a line.
If the end of the stream is reached part-way through the argument list, trailing variables are assigned om.
Comma separation is optional in the representation of tuples and sets.
Examples
If data.txt has the following contents:
4 p 'q r' s t w [x y] z
then after
open("data.txt", "TEXT-IN"); reada("data.txt", a, b); reada("data.txt", c, d); reada("data.txt", e, f); reada("data.txt", g, h);
The variables a..h will be assigned as follows:
- a => 4
- b => 'p'
- c => 'q r'
- d => 's'
- e => 'w'
- f => ['x', 'y']
- g => 'z'
- h => om
Note that 't' is skipped because the third call to read advances to the next line before reading into e.

