Define
The Define() step is where specific data definitions are established by your application and/or process. This involves defining columns/fields and creating the tables/files with optional indices. Below is the code for Define(): /******************************************************** * * * db_create: creates the data files and indices. * * If any of the files already exist there * * will be an error. The files are closed * * so all intended file modes take effect. * * * ********************************************************/ #ifdef PROTOTYPE VOID db_create(void) #else VOID db_create() #endif {
/* Create the data file */ if (CreateDataFile(INVENTDAT,"invent.dat",sizeof(invent),4096,ctVIRTUAL|ctSHARED|ctFIXED)) terminate("Could not create invent.dat",INVENTDAT);
/* the second parameter is no longer used */ if (CloseCtFile(INVENTDAT,0)) terminate("Could not close invent.dat after creation",INVENTDAT);
/* Create the index file */ if (CreateIndexFile(INVENTIDX,"invent.idx",25,0,0,0,4096,ctVIRTUAL|ctSHARED)) terminate("Could not create invent.idx",INVENTIDX);
if (CloseCtFile(INVENTIDX,0)) terminate("Could not close invent.idx after creation",INVENTIDX);
printf("\nSuccessfully created data files and indices");
return; } |
|||