Click or drag to resize

RecNo Function

Return the current record number.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION RecNo() AS DWORD
View Source

Return Value

Type: UInt32
The current record number.  If the work area contains a database file with 0 records, RecNo() returns 1, BOF() and EOF() both return TRUE, and LastRec() returns 0. If the record pointer is moved past the last record, RecNo() returns LastRec() + 1 and EOF() returns TRUE.  If an attempt is made to move before the first record, RecNo() returns the record number of the first logical record in the database file and BOF() returns TRUE.  If no database file is open, RecNo() will return a 0.
Remarks
X# database files are physically ordered by record number.  Each work area in turn maintains a pointer to the current record in its open database file.  That record number is reported by RecNo().  This allows direct access to a record without sequentially scanning the database file to reach the specified record position. Typically, RecNo() generalizes routines that process records by record number. By default, RecNo() operates on the currently selected work area.  It operates on an unselected work area if you specify it as part of an aliased expression (see example below).
Examples
This example queries RecNo() after deliberately moving the record pointer:
X#
USE customer NEW
GO 3
QOut(RECNO())                                // Result: 3
GO TOP
QOut(RECNO())                                // Result: 1
nRecord := 3
GO nRecord
QOut(RECNO())                                // Result: 3
DBGoBottom()
SKIP
QOut(RECNO(), LastRec())                // Result: 11 10
This example uses aliased expressions to query the value of RecNo() in unselected work areas:
X#
USE sales NEW
USE customer NEW
QOut(Sales->RECNO())
QOut(Customer->RECNO())
See Also