<< Click to Display Table of Contents >> Navigation: Apollo API Listing > sx_CreateExec |
Declare Function sx_CreateExec Lib "Apollo9.dll" () As Integer
BOOL FAR PASCAL sx_CreateExec (VOID);
Creates a table in the work area set up via sx_CreateNew and according to the field specifications defined with sx_CreateField.
This function is called as the last in a series of functions used to create a new table. sx_CreateExec only operates upon the structure set up via a call to sx_CreateNew (which sets up a new work area) and calls to sx_CreateField which define the fields in the table.
The new file is physically created by sx_CreateExec. If one or more memo fields have been defined with sx_CreateField, a memo file with the same name as the DBF is created with an extension that reflects the driver in use (SDENTX - DBT, SDEFOX - FPT, SDENSX - SMT).
True or False depending upon the outcome of the operation. It will be False if the preliminary operations have not been called successfully.
Sub ButtonMake_Click ()
iRet = sx_CreateNew( "c:\data\testnew.dbf", "test", SDEFOX, 5)
If iRet = 0 Then
MsgBox "create failed"
Else
sx_CreateField "fchar", "C", 25, 0
sx_CreateField "fnum", "N", 10, 2
sx_CreateField "flog", "L", 1, 0
sx_CreateField "fdate", "D", 8, 0
sx_CreateField "fmemo", "M", 10, 0
If sx_CreateExec() Then
MsgBox "Create succeeded"
sx_Close
Else
MsgBox "create failed"
End If
End If
End Sub
void CNamesForm::OnInitialUpdate()
{
// do default func first
CFormView::OnInitialUpdate();
// enable float support for VBXs
CVBControl::EnableVBXFloat();
// check if database exists and, if not, create
CFileStatus status;
char* pFileName = "names.dbf";
// if CFile status FALSE, create new file
if (!CFile::GetStatus(pFileName, status))
{
sx_CreateNew((BYTEP) "names.dbf", (BYTEP) "name", SDENTX, 5);
sx_CreateField((BYTEP) "name", (BYTEP) "C", 30, 0);
sx_CreateField((BYTEP) "address", (BYTEP) "C", 30, 0);
sx_CreateField((BYTEP) "phone", (BYTEP) "C", 10, 0);
sx_CreateField((BYTEP) "business", (BYTEP) "C", 20, 0);
sx_CreateField((BYTEP) "createdate", (BYTEP) "D", 8, 0);
sx_CreateExec();
sx_Close();
}
}