Input # statement (LotusScript® Language)
Reads data from a sequential file and assigns that data to variables.
Syntax
Input # fileNumber , variableList
Elements
fileNumber
The number assigned to the file when you opened it. A pound sign (#) sign must precede the file number.
variableList
A list of variables, separated by commas. The data read from the file is assigned to these variables. File data and its data types must match these variables and their data types.
variableList cannot include arrays, lists, variables of a user-defined data type, or object reference variables. It can include individual array elements, list elements, and members of a user-defined data type or user-defined class.
Usage
The following table shows how the Input # statement reads characters for various data types.
variableList data type |
How Input # reads characters |
---|---|
Numeric variable |
The next non-space character in the file is assumed to begin a number. The next space, comma, or end-of-line character in the file ends the number. Blank lines and non-numeric values are translated to the number 0. |
String variable |
The next non-space character in the file is assumed to begin a string. Note these special conditions: |
If that character is a double quotation mark ("), it is ignored; however, all characters following it (including commas, spaces, and newline characters) up to the next double quotation mark are read into the string variable. |
|
If the first character is not a double quotation mark, the next space, comma, or end-of-line character ends the string. |
|
Blank lines are translated to the empty string (""). |
|
Note that tab is a non-space character. |
|
Fixed-length string variable |
LotusScript® reads this according to its length. For example, LotusScript® reads a variable declared as String *10 as 10 bytes. |
Variant variable |
The next non-space character in the file is assumed to begin the data. |
If the data is: |
|
Empty (a delimiting comma or blank line), LotusScript® assigns the variable the EMPTY value. |
|
The literal "#NULL#", LotusScript® assigns the variable the NULL value. |
|
A date/time literal, LotusScript® assigns the variable the DataType 7 (Date/Time). |
|
A whole number, LotusScript® assigns the variable the Data Type 2 (integer) if the number is in the legal range for integer; the DataType 3 (Long) if the number is in the legal range for Long but not within the range for integer; and otherwise the DataType 5 (Double). |
|
A number with a fractional part, LotusScript® assigns the variable the DataType 5 (Double). |
|
If none of the preceding applies, LotusScript® assigns the variable the String type. |
If LotusScript® encounters an EOF (end-of-file), input terminates and an error is generated.
LotusScript® inserts "chr(10)" to represent the newline character in any multi-line string (for example, a string that you type in using vertical bars or braces). If you Print the string to a file, this newline character will be translated into the platform-specific newline character(s). If you Write the string to a file, no translation is done.
When reading record-oriented data, using a random file with the Get statement is easier and more efficient than using Input #. Use Get for reading record-oriented data (a random file); use Input # for reading text data (a sequential file).