Writes to disk the current record in the specified work area and updates all affected indexes.
int _DBWrite(int workarea) int workarea; /* Work area. */ |
Remarks
Any time the record pointer is moved to another record, this updating occurs automatically. If no field data has been replaced, _DBWrite(В ) has no effect. _DBWrite(В ) returns 0 if the routine is successful. If the routine fails, _DBWrite(В ) 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 carries out a _DBReplace(В ) using the two calling parameters, one a table field passed by reference, the other a value of the appropriate type. It executes a LIST NEXT 1 Visual FoxPro command before and after a call to _DBWrite(В ).
Visual FoxPro Code
В | Copy Code |
---|---|
SET LIBRARY TO DBWRITE DO CreateTest GO 3 =DBWRITE( @ABC, "Replacement Record 1") 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
В | Copy Code |
---|---|
#include <pro_ext.h> FAR Example(ParamBlk FAR *parm) { int RetValue; if (RetValue = _DBReplace(&parm->p[0].loc, &parm->p[1].val)) { _UserError("\n_DBReplace() failed"); } if (RetValue = _DBWrite(-1)) { _Error(-RetValue); } _Execute("LIST NEXT 1"); } FoxInfo myFoxInfo[] = { {"DBWRITE", (FPFI) Example, 2, "R,?"}, }; FoxTable _FoxTable = { (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo }; |