LKY
Last Key
This string function returns the last key value in a key-access file without changing the current key pointer.
Syntax
Section titled “Syntax”LKY (channel [, SRT=sort-name] [, END=line-ref][,ERR=line-ref|,ERC=error-code])channel- is an integer in the range of 0 to 32764 specifying the channel of an OPEN DIRECT or SORT file. The default is 0.
sort-name- is any string of 20 characters or fewer that specifies the name of a sort sequence in an MSORT file; if not specified, the current sort sequence is used. Specifying a sort-name other than the current sort sequence does not change the current sort sequence for [P]READ and [P]EXTRACT.
line-ref- is the program line number or label to branch to if the file is empty (END=) or an error is produced by this function (ERR=).
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”The SRT= option is only valid for MSORT files. Specifying SRT= does not alter the currently active sort key for [P]READ and [P]EXTRACT, but provides the ability to obtain the values for other sort keys from the LKY of an MSORT file.
If an attempt is made to find LKY on a channel that is not OPEN, an ERR=14 results.
If an attempt is made to find LKY on a channel that is OPEN to a file that is not a key-access file, an ERR=13 results.
If an attempt is made to find LKY on a channel that is OPEN to a file with no data, an
ERR=2 (end of file) results.
The LKY of a DIRECT or SORT file is the key whose value is highest in collating sequence of all keys currently in that file.
Examples
Section titled “Examples”LET LAST_KEY$ = LKY (1, ERR=01000, END=02000)places the key for the file OPEN on channel 1 with the highest collating sequence in LAST_KEY$, branching to program line number 02000 if the file is empty and to statement 01000 if any error other than ERR=2 (end of file) occurs.
See also
Section titled “See also”From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF