Input# Statement [Runtime] /text/sbasic/shared/03020202.xhp Sun Microsystems, Inc. converted from old format - fpe
Input statement Input# Statement [Runtime] Reads data from an open sequential file.
Syntax: Input #FileNumber As Integer; var1[, var2[, var3[,...]]] Parameters: FileNumber: Number of the file that contains the data that you want to read. The file must be opened with the Open statement using the key word INPUT. var: A numeric or string variable that you assign the values read from the opened file to. The Input# statement reads numeric values or strings from an open file and assigns the data to one or more variables. A numeric variable is read up to the first carriage return (Asc=13), line feed (Asc=10), space, or comma. String variables are read to up to the first carriage return (Asc=13), line feed (Asc=10), or comma. Data and data types in the opened file must appear in the same order as the variables that are passed in the "var" parameter. If you assign non-numeric values to a numeric variable, "var" is assigned a value of "0". Records that are separated by commas cannot be assigned to a string variable. Quotation marks (") in the file are disregarded as well. If you want to read these characters from the file, use the Line Input# statement to read pure text files (files containing only printable characters) line by line. If the end of the file is reached while reading a data element, an error occurs and the process is aborted. Example: Sub ExampleWorkWithAFile Dim iNumber As Integer Dim sLine As String Dim aFile As String Dim sMsg as String aFile = "c:\data.txt" iNumber = Freefile Open aFile For Output As #iNumber Print #iNumber, "This is a line of text" Print #iNumber, "This is another line of text" Close #iNumber iNumber = Freefile Open aFile For Input As iNumber While not eof(iNumber) Line Input #iNumber, sLineThis is a LINE INPUT# example, not for INPUT# If sLine <>"" then sMsg = sMsg & sLine & chr(13) end if wend Close #iNumber Msgbox sMsg End Sub