_DBWrite( ) API Library Routine
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
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
#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
};
See Also
_DBLock( ) API Library Routine | _DBReplace( ) API Library Routine | _DBUnlock( ) API Library Routine | Accessing the Visual FoxPro API