IB Statements/key

From CometWiki

Jump to: navigation, search

KEY function

Syntax: KEY(lun [,EXCP=statement-label])

Discussion: The KEY function returns the value of the next key in the keyed file open on the specified logical unit number. The next key is the key following the position of the record pointer. (Keys are stored in ASCII order.)

Notes:

The KEY function is valid only for keyed files.

If the KEY function is attempted on an empty keyed file, an exception 2 (END OF FILE) will be reported.

If the record pointer is currently at the last record in the file, the KEY function will result an exception 2.

The KEY function does not move the record pointer.

Other file-related functions: FIRST, LAST, PREV.

Example:  OPEN (1) "SALES"
.
.
.
NEXTKEY$ = KEY(1,EXCP=9999)

In the above example, the KEY function is used to determine the value of the next key in the SALES file. The resulting value depends upon the statements between the opening of the file (when the pointer is positioned at the beginning of the file) and the execution of the KEY function.

Personal tools