Partager via


_DBRead( ) API Library Routine

Moves the current record pointer to the specified record in the specified work area.

int _DBRead(int workarea, long record)
int workarea;               /* Work area. */
long record;                  /* Record number. */

Remarks

_DBRead( ) returns 0 if the routine is successful. If the routine fails, _DBRead( ) returns a negative integer whose absolute value is a Visual FoxPro error number.

Specifying 0 for record is equivalent to issuing GO TOP; specifying – 1 for record is equivalent to issuing GO BOTTOM.

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 similar functionality to that of the Visual FoxPro command GO. XGO(n) moves the current record pointer to record number n in the current work area.

Visual FoxPro Code

SET LIBRARY TO DBREAD
DO CreateTest
USE Test SHARED
GO BOTTOM
? RECNO()
= XGO(2)
? RECNO()

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)
{
   _DBRead(-1, parm->p[0].val.ev_long);
}

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

See Also

_DBRewind( ) API Library Routine | _DBSkip( ) API Library Routine | _DBUnwind( ) API Library Routine | GO | GOTO Command