Syntax |
Input [#]filenumber%,variable[,variable]... |
||
Description |
Reads data from the file referenced by filenumber into the given variables. |
||
Comments |
Each variable must be type-matched to the data in the file. For example, a String variable must be matched to a string in the file. The following parsing rules are observed while reading each variable in the variable list:
octaldigits[!|#|%|&|@] After reading the number, input is skipped up to the next delimiter—a comma, an end-of-line, or an end-of-file. Numbers must adhere to any of the following syntaxes: [-|+]digits[.digits][E[-|+]digits][!|#|%|&|@] &Hhexdigits[!|#|%|&] &[O]
Normally, dates that follow the universal date format are input from sequential files. These dates use this syntax: #YYYY-MM-DD HH:MM:SS# where YYYY is a year between 100 and 9999, MM is a month between 1 and 12, DD is a day between 1 and 31, HH is an hour between 0 and 23, MM is a minute between 0 and 59, and SS is a second between 0 and 59.
If the input does not begin with a quotation mark, then input is scanned up to the next comma, end-of-line, or end-of-file and a determination is made as to what data is being represented. If the data cannot be represented as a number, Date, Error, Boolean, or Null, then it is read as a string. The following table describes how special data is interpreted as variants: |
||
|
|
Blank Line |
Read as an Empty variant |
|
|
#NULL# |
Read as a Null variant. |
|
|
#TRUE# |
Read as a Boolean variant. |
|
|
#FALSE# |
Read as a Boolean variant. |
|
|
#ERROR code# |
Read as a user-defined error. |
|
|
#date# |
Read as a Date variant. |
|
|
"text" |
Read as a String variant. |
|
If an error occurs in interpretation of the data as a particular type, then that data is read as a String variant. When reading numbers into variants, the optional type-declaration character determines the VarType of the resulting variant. If no type-declaration character is specified, then The Basic Control Engine will read the number according to the following rules: Rule 1: If the number contains a decimal point or an exponent, then the number is read as Currency. If there is an error converting to Currency, then the number is treated as a Double. Rule 2: If the number does not contain a decimal point or an exponent, then the number is stored in the smallest of the following data types that most accurately represents that value: Integer, Long, Currency, Double.
The filenumber parameter is a number that is used by The Basic Control Engine to refer to the open file, the number passed to the Open statement. The filenumber must reference a file opened in Input mode. It is good practice to use the Write statement to write date elements to files read with the Input statement to ensure that the variable list is consistent between the input and output routines. |
||
Example |
This example creates a file called test.dat and writes a series of variables into it. Then the variables are read using the Input# function. Const crlf = Chr$(13) + Chr$(10) Sub Main() Open "test.dat" For Input As #1 |
||
See Also |
Open (statement); Get (statement); Line Input# (statement); Input, Input$ (functions). |
I |