FutureBasic Logo

<<    Index    >> FutureBasic

line input and line input$   function / statement



Syntax 1
[ cfString = ] line input fileID [, @err ]

Syntax 2
line input# deviceID, stringVar&

Description
Syntax 1
This function reads a line of text from the open file specified by fileID into the CFString variable cfString.
It optionally returns an ErrorRef in @err.

Important note: line input's syntax 1 must be matched with the correct open method for use with CFStrings. See syntax 1 for open.

Syntax 2
This statement reads a line of text data from the open file or open serial port specified by deviceID, and stores the data into the string variable stringVar$.
If deviceID equals zero, then line input# reads data from the keyboard. line input# 0,stringVar$ is identical to line input stringVar$.
If deviceID specifies a file, then line input# reads a line of text from the file, beginning at the current "file mark" position (which is usually at the beginning of the line), and ending when a carriage-return character is encountered, or the end of the file is encountered, or 255 characters have been read, whichever occurs first. line input# then assigns the entire string of characters to stringVar$. the file mark is then advanced to a position just past the last character read.
If deviceID specifies a serial port (i.e., if its value is _modemPort or _printerPort), then line input# behaves in a similar way, except that the concepts of "file mark" and "end of file" generally don't apply.

Note that line input# is similar to input#, except that special characters such as commas, quotes and leading spaces are not interpreted as data item delimiters, but instead are copied directly into stringVar$.

Important note: line input's syntax 2 must be matched with the correct open method for use with pascal strings. See syntax 2 for open.

Note
If the file mark is already at the end of the file when you execute line input#, FutureBasic generates an "Input past end of file" error. To prevent this situation, check the value of eof(deviceID) before executing line input#.

See also
input#; eof; open