This function creates an empty database file. DBBLOCK is a pointer to a structure that the database maintains. This block allows the engine to keep track of the opened database. The DBBLOCK structure can be examined, but should not be modified.
If a file exists with the path pointed to by filename, DB_Create removes that file. If the database creation fails either because of lack of disk space or lack of memory, the partial database file is removed.
The filetype is a unique character supplied by the application that indicates the type of file (i.e. Appointment book, Phone Book, etc.). This field is not used by the database, but can be used by applications to determine if the database file is of the proper type.
Creating a database with filetype=0 allows that file to be read into any database application; DB_Opening an existing database file and passing filetype=0 allows the application to open any database file type. The file types of the built-in applications are
'D' Phonebook/General Database file (same format). All data in
records accessible through fielddefs.
'N' Notetaker file. All data is accessible through
FieldDefs.
'2' Appointment book file. Not all data is accessible through
fielddefs. Appointment Book files may have embedded links to other
records.
'W' World Time file. All data in records is accessible, however
most data records are ROM resident. World Time files require
ROMCallBack and ROMCount to be correctly set to
open properly.
The ROMCount and ROMCallBack fields are 0, unless the application requires ROM record support. See Miscellaneous:ROMCallBack for more details.
The date and time of the file's creation are recorded in the last reconciled field in the header block. They will indicate the original creation date of the file (unlike DOS's file timestamp). Reconciliation software should reset this time and date after reconciling the contents with another copy of the database.
Syntax: int DB_Create(DBBLOCK *dblk, char *filename, char filetype,
int (far *FieldCallBack)(),int ROMCount, int (far*ROMCall-
Back)());
Returns: DB_OK Database was created.DB_CREATE File cannot be created. (not enough handles, bad filename, etc.)
DB_MEMORY Not enough memory to open the created file.
DB_WRITE Not enough disk space; bad media.
DB_PROTECTED File is on protected media.
DB_OPEN Created file cannot be opened.
DB_READ Cannot read from new file.
DB_SEEK Cannot seek within file; media may bad.
May Move Memory: Yes