Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
An <input-statement> reads data from the file underlying <marked-file-number>.
-
input-statement = "Input" marked-file-number "," input-list input-list = input-variable *[ "," input-variable] input-variable = bound-variable-expression
Static Semantics.
§ The semantics of <marked-file-number> in this context are those of a <file-number> element that consisted of that same <marked-file-number> element.
§ The <bound-variable-expression> of an <input-variable> MUST be classified as a variable.
§ The declared type of an <input-variable> MUST NOT be Object or a specific name class.
Runtime Semantics.
An error (number 52, "Bad file name or number") is raised if the file number value (section 5.4.5.1.1) of <file-number> is not a currently-open (section 5.4.5.1) file number (section 5.4.5).
An <input-statement> reads data (starting from the current file-pointer-position) into one or more variables. Characters are read using the file number value until a non-whitespace character is encountered. These whitespace characters are discarded, and the file-pointer-position now points at the first non-whitespace character.
The following process occurs for each <input-variable> in <input-list>:
If the declared type of <input-variable> is String then it is assigned a sequence of characters which are read from the file, defined as:
If the first character read is a DQUOTE then the sequence of characters is a concatenation of all characters read from the file until a DQUOTE is encountered; neither DQUOTE is included in the sequence of characters. The file-pointer-position now points at the character after the second DQUOTE. The beginning and ending DQUOTEs are not included in the String assigned to <input-variable>.
If the first character read is not a DQUOTE then the sequence of characters is a concatenation of all characters read from the file until a "," is encountered. The "," is not included in the sequence of characters. The file-pointer-position now points at the character after the ",".
If the declared type of <input-variable> is Boolean then it is assigned the value false, unless the sequence of characters read are "#TRUE#". If the sequence of characters is numeric an "Overflow" error is generated (error number 6). The file-pointer-position now points at the character after the second "#". o If the declared type of <input-variable> is Date then a sequence of characters is read from the file, according to the following rules:
If the first character at file-pointer-position is "#", then characters are read until a second "#" is encountered. At this point the concatenated String of characters is Let-coerced into <input-variable>.
If the first character at file-pointer-position is not "#", then error 6 ("Overflow") is generated.
If the sequence of characters are all numbers or characters which are valid in a VBA number (in other words, ".", "e", "E", "+", "-") then the characters are concatenated together into a string and Let-coerced into the declared type of <input-variable>. The file-pointer-position now points at the first non-numeric character it encountered.
If the sequence of characters is surrounded by DQUOTEs and the declared type of <input-variable> is not String or Variant, then <input-variable> is set to its default value.
In this case the file-pointer-position now points at the first character after the second DQUOTE. If this character is a "," then the file-pointer-position advances one more position.
If the sequence of characters read from the file are "#NULL#" then the Null value is Let-coerced into <input-variable>. If the sequence of characters read from the file are "#ERROR " followed by a number followed by a "#" then the error number value is Let-coerced into <input-variable>.
If one of the operations described in this section causes more characters to be read from the file but file-pointer-position is already pointing at the last character in the file, then an "Input past end of file" error is raised (error number 62).
Each <input-variable> defined in <input-list> is processed in the order specified; if the same underlying variable is specified multiple times in <input-list>, its value will be the one assigned to the last <input-variable> in <input-list> that represents the same underlying variable.