1. Declaring the HyperFileSQL context and the working buffers of each file:
If the application must manage data files, a HyperFileSQL working context must be declared as well as a buffer for each data file.
These declarations are performed in the Vc60.dsp project via the following lines:
CHFContext gclHF; // Management of the HyperFileSQL context
StCITY gstCity; // HF buffer of City file
StSTATE gstState; // HF buffer of State file
2. Initializing the WINDEV DLLs
The first step before using the elements developed in WINDEV is to load the WINDEV DLLs in memory and to initialize them.
These operations are performed by calling the
nWDInit function at the beginning of your Procedure
WinMain as follows:
if (nWDInit(FALSE)!=WDERROR_OK) ... // manage the error case
3. Initializing HyperFileSQL
If your application is calling a database, the access to HyperFileSQL must now be prepared. The test below is used to check whether this initialization is performed properly:
IHFContext * pIHF;
if (!((nWDGetHFContext((void**)&pIHF)==WDERROR_OK) &&
(gclHF.bInit(pIHF))))
{
// manage the error case
}
4. Loading the WINDEV library (WDL)
The WINDEV library (.WDL extension) contains all the project elements (windows, reports, classes, queries, analysis, ...). Therefore, it must be loaded in memory in order for its components to be called.
The load operation is performed by
nWDOpenWDL as follows:
if (nWDOpenWDL(szWDL)!=WDERROR_OK)
{
// Library not found
}
5. Opening the project analysis and associating buffers with the data files
Opening the analysis allows you to call the data files. Once this analysis has been opened by /HOpenAnalysis, all you have to do is associate the working buffers with the files described in this analysis:
// Open the analysis (WDD contained in the WDL)
if (!gclHF.HOpenAnalysis(szAnalysis,szPassword))
{
// Error opening the analysis
}
// Buffer <-> file association
gclHF.bAssociate("city",&gstCity,sizeof(gstCity));
gclHF.bAssociate("state",&gstState,sizeof(gstState));