READLN - read line from text file.
Usage:
readln(f,v);
Where:
- f
- is a file variable that has been opened for reading using
"reset", "openf", or some other
means. It must have the type "text". If this
argument is omitted, the default input unit
"input" is assumed.
- v
- is a variable whose type is "char",
"integer", a subrange of either
"char" or "integer",
"real", or "packed array [1..N] of
char". If this argument is omitted,
"readln" simply discards the rest of the line
it is reading, up to and including the new-line character
on the end.
Description:
The "readln" procedure reads an input line from the
text file "f" and stores values obtained from that line
in the variable "v". Any text remaining on the line is
discarded, up to and including the new-line character on the end.
- If "v" has the type "char", a single
character is placed in "v" from the
"text" file.
- If "v" has the type "integer" (or
some integer subrange), the "readln" procedure
will skip through blanks, tabs, and new-line characters
until it finds a digit or a sign (+ or -). It will then
gather digits until it finds a character that cannot be
part of an integer constant. The integer that is gathered
in this way will be assigned to the variable
"v". (If the first non-blank character that
"readln" finds is NOT valid in an integer,
"readln" will issue an error message.)
- If "v" has the type "real", the
"readln" procedure skips white space characters
and gathers a real constant in much the same way that it
gathers an integer.
- If "v" has the type "packed array [1..N]
of char", "readln" will assign input
characters to the array elements beginning with number 1.
It stops when it fills the array or when it reaches a
new-line character in the input, whichever comes first.
A call of the form
readln(f,v1,v2,v3,...,vN);
is equivalent to
read(f,v1);
read(f,v2);
...
read(f,vN);
readln(f);
See Also:
expl pascal lib read
expl pascal lib get
Copyright © 1996, Thinkage Ltd.