bas7advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
READ Statement Details
  ◄Syntax►  ◄Details►  ◄Example►                 ◄Contents►  ◄Index►  ◄Back►
──────────────────────────────────────────────────────────────────────────────
The READ statement reads values from a DATA statement and assigns the
values to variables.
 
READ variablelist
    ■ Each variable in a READ statement receives its value from some DATA
      statement. Which value the variable receives depends on how many
      values have previously been read. The values of all DATA statements
      in a module can be considered as a single list of values. Each
      value in this list is assigned in turn to the variables specified
      in READ statements. It doesn't matter how many values are specified
      in a given DATA statement or how many variables are specified in a
      READ statement. If you attempt to read more values than are
      specified in all the statements combined, BASIC generates the error
      message, "Out of Data."
    ■ The following table describes what happens when you try to read data
      of one data type into a variable with a different data type:
 
      When you try to
      read this:         Into this:          The result is:
      ═══════════════    ═════════════════   ═══════════════════════════════
      String value       Numeric variable    A run-time error.
 
      Numeric value      String variable     The value is stored as a string
                                             of numerals (no error produced).
 
      Any numeric value  Integer variables   The value is rounded before
                                             it is assigned to the variable.
 
      Numeric value      A variable not      A run-time error.
                         large enough to
                         handle the numeric
                         variable.
 
      String value       Fixed-length        Truncated if the string is
                         string variables    too long; left-justified and
                                             padded with blanks if the
                                             string is shorter than the
                                             variable.
 
    ■ Only individual elements of a record variable can appear in a READ
      statement.
    ■ Use the RESTORE statement to reread DATA statements.