Input# (statement)

About this task

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:

Procedure

  1. Leading white space is ignored (spaces and tabs).
  2.  When reading String variables, if the first character on the line is a quotation mark, then characters are read up to the next quotation mark or the end of the line, whichever comes first. Blank lines are read as empty strings. If the first character read is not a quotation mark, then characters are read up to the first comma or the end of the line, whichever comes first. String delimiters (quotes, comma, end-of-line) are not included in the returned string.
  3. When reading numeric variables, scanning of the number stops when the first nonnumber character (such as a comma, a letter, or any other unexpected character) is encountered. Numeric errors are ignored while reading numbers from a file. The resultant number is automatically converted to the same type as the variable into which the value will be placed. If there is an error in conversion, then 0 is stored into the variable.
      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]
  4. When reading Boolean variables, the first character must be #; otherwise, a runtime error occurs. If the first character is #, then input is scanned up to the next delimiter (a comma, an end-of-line, or an end-of-file). If the input matches #FALSE#, then FALSE is stored in the Boolean ; otherwise TRUE is stored.
  5. When reading Date variables, the first character must be #; otherwise, a runtime error occurs. If the first character is #, then the input is scanned up to the next delimiter (a comma, an end-of-line, or an end-of-file). If the input ends in a # and the text between the #'s can be correctly interpreted as a date, then the date is stored; otherwise, December 31, 1899, is stored.
    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.
  6. When reading Variant variables, if the data begins with a quotation mark, then a string is read consisting of the characters between the opening quotation mark and the closing quotation mark, end-of-line, or end-of-file.
    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:
  7. End-of-line is interpreted as either a single line feed, a single carriage return, or a carriage-return/line-feed pair. Thus, text files from any platform can be interpreted using this command.
    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.