# A.3 FIND Statement

The FIND statement positions a direct access file at a particular record and sets the associated variable of the file to that record number. It is comparable to a direct access READ statement with no I/O list, and can open an existing file. No data transfer takes place.

The FIND statement takes one of the following forms:

    FIND (u'r [,ERR=s] [,IOSTAT=ios])

    FIND ([UNIT=]u, REC=r [,ERR=s] [,IOSTAT=ios])

u
  Is a logical unit number. It must refer to a relative organization file.
r
  Is the direct access record number. It cannot be less than one or greater than the number of records defined for the file.
s
  Is the label of the executable statement that receives control if an error occurs.
ios
  Is an integer scalar memory reference that is defined as a positive integer if an error occurs, and as zero if no error occurs.

Examples

In the following example, the FIND statement positions logical unit 1 at the first record in the file. The file's associated variable is set to one:

    FIND (1, REC=1)

In the following example, the FIND statement positions the file at the record identified by the content of INDX. The file's associated variable (REC) is set to the value of INDX:

    FIND (4, REC=INDX)

For More Information:

For details on associate variables, see the ASSOCIATEVARIABLE keyword (Section 10.6.2 for Tru64 UNIX details, or Section 9.6.2 for OpenVMS details) and the DEFINE FILE statement in Section A.1.

Previous Page Next Page Table of Contents