line input # - read a line from a sequential file
Line input #
reads a line of characters into a program variable,
discarding the newline that terminates the line.
line input #
calls may be used to read the file line by line.
FileNum is the file number under which the file to be read was opened.
StrVar is the name of a string variable or string array element to which the
line will be assigned.
The following example uses
line input #
to get one line from a sequential file, and print it out.
open "infile" for input as #2
line input #2, inline$
In Microsoft BASIC, line input is used for input from the userís keyboard
(terminal) and line input # is used for input from disk files. In the
UNIX environment, the distinction between terminals and disk files is not
as strong: standard input may be redirected to a disk file or a terminal
may be open as a file. To accommodate this flexibility, the distinction
between line input and line input # must be merely syntactic rather
than functional. Thus,
line input StrVar
is the synopsis of the line input statement for disk file input (as
described above) when standard input is redirected to a disk file.
Although the organization of these manual pages implies the older,
less flexible system, this organization is maintained only for
convenience, line input and line input # do not differ functionally.
The difference in behavior between terminal input and disk file input
depends entirely upon the type of file in use.
If FileNum is less than 1 or greater than the maximum number of
open files, or if FileNum is not open, a "Bad file number" error occurs.
If FileNum is open for random access, an "Illegal function call"
An "Input past end" error occurs when an attempt is made to
read beyond the end of the file.
The Basmark QuickBASIC Programmerís Manual