HP Pascal/iX Reference Manual (31502-90022)

10- 16
faulty sequence of characters, or if the value is outside the range of
v
.
After
read
, a subsequent reference to the buffer variable
f
^ actually
loads the buffer with the character immediately following the number
previously read. Also note that eof is false if a file has more blanks
or line markers, even though it contains no more numeric values.
If
v
is a variable of type string or PAC, then read(
f, v
) fills
v
with
characters from
f
up to the number of elements of
v
. When
v
is type PAC
and eoln(
f
) becomes true before
v
is filled, the operation puts blanks in
the rest of
v
. If
v
is type string and eoln(
f
) becomes true before
v
is
filled to its maximum length, no blank padding occurs. Strlen(
v
) then
returns the actual number of characters in
v
. If eoln(
f
) is true when
the call is made, no additional characters are read from
f
. The length
of a string variable is set to zero, and PAC variables are filled with
blanks. Readln must be used to proceed to the next line.
If
v
is a variable of an enumerated type, read(
f, v
) searches
f
for a
sequence of characters satisfying the syntax of an HP Pascal identifier.
The search skips preceding blanks and line markers. Then the operation
compares the identifier from
f
with the identifiers which are values of
the type of
v
, ignoring upper and lower case distinctions. Finally, it
assigns an appropriate value to
v
. It is an error if the search finds no
non-blank characters, if the string from
f
is not a valid HP Pascal
identifier, or if the identifier does not match one of the identifiers of
the type of
v
.
Table 10-2 shows the results of calls to read with various sequences
of characters for different types of
v
.
Table 10-2. Implicit Data Conversion
----------------------------------------------------------------------------------------------
| | | |
| Sequence of Characters in f | Type of v | Result Stored in v |
| Following Current Position | | |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| (space)(space)1.850 | real | 1.850 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| (space)(linemarker)(space)1.850 | longreal | 1.850 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 10000(space)10 | integer | 10000 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 8135(end-of-line) | integer | 8135 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 54(end-of-line)36 | integer | 54 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 1.583E7 | real | 1.583x10(7) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| 1.583E+7 | longreal | 1.583x10(7) |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| (space)Pascal | string[5] | '_Pasc' |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| (space)Pas(end-of-line)cal | string[9] | '_Pas' |
| | | |