FKY
First Key
This string function returns the first key value in a DIRECT or SORT file without changing the current key pointer.
Syntax
Section titled “Syntax”FKY (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 file.
sort-name- is a 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 FKY of an MSORT file.
If an attempt is made to find the first key on a channel that is not OPEN, an ERR=14 results.
If an attempt is made to find the first key 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 the first key on a channel that is OPEN to a file with no data, an ERR=02 (end of file) results.
The first key of a key-access file is the key whose value is lowest in collating sequence of all keys currently in that file.
Examples
Section titled “Examples”LET FIRST_KEY$ = FKY (1, END=1000, ERR=2000)sets the string variable FIRST_KEY$ to the first key of the file OPEN on channel 1, branches to statement 1000 if the file is empty, and branches to statement 2000 if an error other than END 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