_FFlush( ) API Library Routine Example

The following example creates a file and sets its length to 8196 bytes. Executing the Visual FoxPro command line DIR TEMP.TXT in the Command window shows that the size of the file on disk is still 0. However, after executing = XFFLUSH( ), issuing the command line DIR TEMP.TXT shows that the file on disk reflects the _FCHSize( ) call, and has a file size of 8196 bytes.

Visual FoxPro Code

SET LIBRARY TO FFLUSH  
DIR temp.txt  && size on disk is still 0
WAIT WINDOW "File Size = 0"
= XFFLUSH()
DIR temp.txt  && size on disk is 8196
WAIT WINDOW "File Size Does Not Equal 0"
CLOSE ALL

C Code

#include <pro_ext.h>

static FCHAN fchan;

FAR CreateIt(ParamBlk FAR *parm)
{
   fchan = _FCreate("temp.txt", FC_NORMAL);
   _FCHSize(fchan, 8196);
}

FAR FFlushEx(ParamBlk FAR *parm)
{
   _FFlush(fchan);
}

FoxInfo myFoxInfo[] = {
   {"ONLOAD", (FPFI) CreateIt, CALLONLOAD, ""},
   {"XFFLUSH", (FPFI) FFlushEx, 0, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};