Purpose
Read in formatted data
from the active input stream.
Synopsis
procedure read(e1:expr[, e2:expr...])
procedure readln
procedure readln(e1:expr[, e2:expr...])
Argument
e1, e2,...
|
Expression or list of expressions of basic type
|
Example
The following reads (possible split over several lines)
12 45 word, followed by
toto(12 and 45)=word:
declarations
i,j:integer
s:string
ts:array (range,range) of string
end-declarations
read(i, j, s)
readln("toto(", i, "and", j, ")=", ts(i,j))
Further information
1. These procedures assign the data read from the active input stream to the given symbols or try to match the given expressions with what is read from the input stream. If
ei is a symbol that can be assigned a value, the procedure tries to recognise from the input stream a constant of the required type and, if successful, assigns the resulting value to
ei. If
ei is a constant or a symbol that cannot be reassigned, the procedure tries to read in a constant of the required value and succeeds if the resulting value corresponds to
ei. These procedures do not fail but set the control parameter
nbread to the number of items actually recognized.
2. Note that the
read procedures are based on the lexical analyser of Mosel: items are separated by spaces and a string that contains spaces must be quoted using either single or double quotes (the quotes are automatically removed once the string has been identified).
3. The procedure
readln expects all the items to be recognized to be contained in single line. The function
read ignores changes of line. If the procedure
readln is used without parameters it skips the end of the current line.
Related topics
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the
property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not
convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except
solely for internal evaluation purposes to determine whether to purchase a license to the software
described in this documentation, or as otherwise set forth in a written software license agreement
between you and FICO (or a FICO affiliate). Use of this documentation and the software described in
it must conform strictly to the foregoing permitted uses, and no other use is permitted.