FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-84
POSITION Statement
When performing a GENERIC file search on an alternate key, the record made
available to the program is the first one that satisfies the search requirements. If
you want a later record, you can use the COMPARELEN specifier to include
characters of the primary key in the alternate key comparison. For example, if you
are searching for the alternate key 'RIVET', and it is known that part numbers (the
primary key) in the 12100 range refer to 1-inch rivets, the 12200 range to 2-inch
rivets, and so on, a key value of RIVET 122 with a COMPARELEN=8 specifier can
concatenate the first three characters of the primary key with the 5-character
alternate key to narrow the search. The value you specify with COMPARELEN is
therefore the sum of the full length of the key plus additional characters from the
primary key.
Do not use this specifier if you are performing an EXACT search or using the
primary key.
If you omit this specifier, the compiler assumes a value of 0 for COMPARELEN.
SKIPEXACT specifier
If you are using an alternate key to perform a file search, the first record found that
specifies the search requirements is made available to the program. If you save
the key values of that record and use them in a subsequent search, the same
record is found. If you specify SKIPEXACT='YES', the record that exactly matches
the previously found record is skipped and the next record with the same alternate
key is made available.
If you omit this specifier, the compiler assumes a value of 'NO' for the SKIPEXACT
specifier.
Note that you can use this specifier with primary keys thus allowing a FORTRAN
server to read the next record in a file and remain context free.
Direct Access
You can use the REC specifier only with EDIT format files, unstructured files, and
relative disk files. In all of these file types, records are identified by INTEGER*4
record number values. You do not need to use a POSITION statement to position
direct access files. The compiler treats any READ or WRITE statement containing
a REC= specifier as a POSITION statement followed by a sequential READ or
WRITE statement.
If you do use a POSITION statement, a subsequent READ statement reads the
record with the smallest record number that is greater than or equal to the
specified record number. A WRITE statement inserts or replaces a record with the
specified record number.
To append new lines at the end of an EDIT format file, OPEN the file and execute a
POSITION or WRITE statement, with REC= -2.
You cannot POSITION an EDIT format file in a FORTRAN program that is running
as a NonStop process.