Function RecNo() Foundation

Returns a value which clearly identifies the current record.

Syntax
RecNo() --> xRecordID
Return

The function RecNo() returns a value (referred to as the record ID) identifying the current record in a work area. The data type of this record ID is predetermined by the file format of the data files. For DBF files, the record ID is a numeric value designating the data record number. When no records are available in a work area, RecNo() returns the value of LastRec()+1 and the functions Bof() and Eof() both provide the value .T. (true). When no file is opened, zero is returned.

Description

The database function RecNo() determines the record ID of the current record in a work area. When the function is used without the alias operator, it returns the record ID of the current record in the current work area. For DBF files, this is the record number and is a numeric value. For another file format it might be a value for the primary key which does not have to be numeric.

Examples
RecNo()
// The example illustrates the return value of RecNo() 
// when the record pointer is moved several times. 

PROCEDURE Main 
   USE Customer NEW 

   ? RecNo()               // result: 1 
   ? LastRec()             // result: 100 

   SKIP 
   ? RecNo()               // result: 2 

   GO 20 
   ? RecNo()               // result: 20 

   SKIP -5 
   ? RecNo()               // result: 15 

   SKIP -20 
   ? RecNo()               // result: 1 
   ? Bof()                 // result: .T. 

   GO BOTTOM 
   ? RecNo()               // result: 100 

   SKIP 
   ? RecNo()               // result: 101 
   ? Eof()                 // result: .T. 

   USE 
RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.