HP Pascal/iX Reference Manual (31502-90022)

9- 9
strread
Usage
strread
(s, p, t, v)
strread
(s, p, t, v1,...,vn)
Parameters
s
A string expression.
p
An integer expression.
t
An integer or integer subrange variable.
v
A simple, string, or PAC variable. Any number of
v
parameters
may appear separated by commas.
Description
The procedure strread
(s, p, t, v)
reads a value from
s
, starting at
s [ p
]
, into the variable
v
. After the operation, the value of the variable
appearing as the
t
parameter will be the index of
s
immediately after the
index of the last component read into
v
.
S
is treated as a single-line textfile. Strread
(s, p, t, v)
is analogous
to read
(f, v)
when
f
is a textfile of one line. Like read, strread
implicitly converts a sequence of characters from
s
into the types
integer, real, longreal, Boolean, enumerated, PAC, or string.
It is an error if strread attempts to read beyond the current length of
s
.
The call:
strread (s,p,t,v1,...,vn);
is equivalent to:
strread (s,p,t,v1);
strread
(s,t,t,v2);
.
.
strread
(s,t,t,vn);
Example
VAR
s: string[80];
p,t: 1..80;
m,n: integer;
BEGIN
.
s:= ' 12 564 ';
.
p:= 1;
strread(s,p,t,m); { The value of m will be 12; }
. { t will be 6. }
.
strread(s,t,t,n); { The value of n will be 564; }
. { t will be 11. }
END.