input # - read from sequential file


input #FileNum, Var[, Var]... 


Input # is used to read data from a sequential file into program variables.  FileNum is the number used when the file was open for input.  Var (which may be a string or numeric variable, or an array element) is the name of the variable that will have an item in the file assigned to it.  File data and program variables must match by type (string or numeric).  Unlike input, no question mark is displayed with input #.  For both numeric and string data, leading spaces, carriage returns, and line feeds are assumed to be white space and are ignored.  Commas are interpreted as field separators.  Numeric data is assumed to begin with a digit or decimal point.  If an invalid character is encountered, the return value will be zero.  String data is assumed to begin with the first character that is not white space or a separator and continues until the first comma, carriage return, or line feed is encountered.  If the first character of a string is a quotation mark Ď"í, the string item will consist of all the characters read between this and the next quotation mark (a quoted string may not, therefore, contain quotation marks). 


With a sequential file:
	open "addrph" for input as 1
	input #1, a$
	close #1
	print a$
With a random file:
	open "addrph" as #1 len=80
	field #1, 40 as n$
	get #1
	input #1, a$
	close #1
	print a$


input, input$


In Microsoft BASIC, input is used for input from the userís keyboard (terminal) and 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 input and input # must be merely syntactic rather than functional.  Thus,

input Var[, Var]... 

is the synopsis of the 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, input and 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. 


A "Bad file number" error occurs if FileNum does not refer to an open file. 

An "Illegal function call" error occurs if the file is open for output only. 

An "Input past end" error occurs if the number of data items remaining is less that the number of items expected. 

An "Overflow" error occurs if the value of a data item exceeds the precision of the associated variable. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber