IB Statements/recnum

From CometWiki

Jump to: navigation, search

RECNUM function

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

Discussion: The RECNUM function returns the record number (numeric) of the file that is open on the specified logical unit number.

Notes:


For all file types except keyed files, for all numeric reads, the record pointer is advanced one record after the read. This is the way to read through a file. Reads can be either numeric indexed reads (indexed sequential files) or reads without an index (sequential files). Either kind of read advances the record pointer. The recnum function returns the current record pointer.

For keyed files the record pointer is derived from the last keyed read or read without a key. In either case, the read is done through the key tree and the record pointer is whatever that last index points to. When a numeric index is used on a keyed file, the record pointer is not advanced. It would make no sense to advance it because the order of a keyed file is dependent on the key order not the order of the records.

Example:

 OPEN (1) "ORDERS"
 .
 .
 .
 RECORDNUM = RECNUM(1,EXCP=9999)

In the above example, the RECNUM function is used to determine the value of the record number in the ORDERS file. If an exception occurs when this statement is executed, program control will transfer to exception-statement-label 9999.

Personal tools