READLAST, READLASTLK
The READLAST instruction retrieves information from disk and transfers that information into data variables. It is exactly like the AAM READ instruction except that the READ instruction returns the first matching record, whereas READLAST returns the last matching record. The instruction uses the following formats:
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
afile
Required. A previously defined and opened AFILE variable from which data is read.
key
Required. One or more previously defined Character String Variables, Numeric Variables, or VARLISTs of string or numeric variables that select the record to read.
list
Optional. Any combination of previously defined Character String Variables, or Numeric Variables, string or numeric ARRAYS, individual array elements, VARLISTs of string or numeric variables, or valid Disk I/O List Controls.
;
Optional. A semicolon indicating Partial I/O.
Flags Affected: LESS, OVER, ZERO
Note the following:
If the manual record locking mode is in effect, the READLASTLK form locks the record as it is read.
If the automatic record locking mode is in effect, all forms of this instruction lock the record as it is read.
This instruction operates by positioning to the end of file and reading backwards.
See the AAM READ instruction for all other details.
When using the single unlocking mode, a read to a record that is not locked unlocks the currently locked record before the read is attempted.
If a locking conflict occurs, the read fails and the following actions take place:
The LESS Condition Flag is set and the OVER Condition Flag is cleared.
All variables are left in their original state unless the PLB_RDCLR environment variable is set for PLBCMP. If set, all DIM fields are CLEARed and all FORM fields are set to zero.
The current data file position and the sequential data file position are set to the position of the locked record.
The update data file position is set to invalid.
The index file position is set to the position in the retrieval set of the locked record.
Record Locking was added in version 8.2 and is not available when using the PLBCE runtime.
See Also: Disk I/O Instructions
![]() |