Condividi tramite


_DBRecCount( ) API Library Routine

Returns the total number of records in the table open in the specified work area.

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

Remarks

If no table is open in the specified work area, _DBRecCount( ) returns a negative integer whose absolute value is a Visual FoxPro error number.

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 calls _DBRecCount( ) to count the number of records in the table open in the current work area.

Visual FoxPro Code

SET LIBRARY TO DBRECCNT
DO CreateTest
? DBRECCOUNT()   && call API routine
? RECCOUNT()   && call built-in Visual FoxPro Function

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"
   GO TOP
RETURN

C Code

#include <pro_ext.h>

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

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

See Also

_DBRecNo( ) API Library Routine | Accessing the Visual FoxPro API | Working with Records | Records | Working with Fields and Records