Share via


_DBRecNo( ) API Library Routine

Returns the number of the current record in the table open in the specified work area.

long _DBRecNo(int workarea)
int workarea;               /* Work area. */

Remarks

If no table is open in the specified work area, _DBRecNo( ) returns a negative integer whose absolute value is a Visual FoxPro error number. If the record pointer is at the end of file, _DBRecNo( ) returns a number that is 1 greater than that returned by _DBRecCount( ).

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example provides functionality similar to that of the Visual FoxPro RECNO( ) function.

Visual FoxPro Code

SET LIBRARY TO DBRECNO 
DO CreateTest
GO 3
? DBRECNO()
GO 6
? DBRECNO()
USE
? DBRECNO()  && returns -119

PROCEDURE CreateTest
   CREATE TABLE test (ABC C(20))
   APPEND BLANK
   REPLACE ABC WITH "This is record 1"
   APPEND BLANK
   REPLACE ABC WITH "This is record 2"
   APPEND BLANK
   REPLACE ABC WITH "This is record 3"
   APPEND BLANK
   REPLACE ABC WITH "This is record 4"
   APPEND BLANK
   REPLACE ABC WITH "This is record 5"
   APPEND BLANK
   REPLACE ABC WITH "This is record 6"
   GO TOP
RETURN

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   _RetInt(_DBRecNo(-1), 10);
}

FoxInfo myFoxInfo[] = {
   {"DBRECNO", (FPFI) Example, 0, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Concepts

API Library Routines A-Z

Reference

_DBRecCount( ) API Library Routine

Records

Other Resources

Accessing the Visual FoxPro API

Working with Records

Field and Record Manipulation

API Library Routines by Category