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.
FIELD Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
FIELD allocates space for variables in a random-access file buffer.
 
FIELD [#]filenumber%, fieldwidth% AS stringvariable$
                    [,fieldwidth% AS stringvariable$] ...
    ■ The argument filenumber% is the number used in the OPEN statement
      to open the file.
    ■ The argument stringvariable$ is a string variable that contains the
      data read from a record, or data used in an assignment when
      information is written to a record.
 
Usage Notes
    ■ The total number of bytes that you allocate in a FIELD statement
      must not exceed the record length that you had specified when
      opening the file. Otherwise, BASIC generates the error message,
      "FIELD overflow." (The default record length is 128 bytes.)
    ■ Any number of FIELD statements can be executed for the same file.
      All FIELD statements that have been executed remain in effect at
      the same time.
    ■ All field definitions for a file are removed when the file is
      closed; that is, all strings defined as fields associated with the
      file are set to null.
 
Important
    ■ Do not use a variable name defined as a field in an INPUT or
      assignment statement if you wish the variable to remain a field.
      Once a variable name is a field, it points to the correct place in
      the random-access file buffer. If a subsequent INPUT or assignment
      statement with that variable name is executed, the variable's
      pointer no longer refers to the random-access record buffer, but to
      string space.
 
Programming Tips
    ■ BASIC's record variables and extended OPEN statement syntax
      provide a more convenient way to use random-access files.
 
Differences from BASICA
    ■ When a random-access file is closed with a CLOSE or RESET statement
      in a compiled program, all variables that are fields associated with
      that file are reset to null strings. When a random-access file is
      closed in a BASICA program, variables that are fields retain the last
      value assigned to them by a GET statement.