// allocate an array of FLDDesc structures, one struct for each field to // be defined; in this examples there are 3 fields FLDDesc* pFieldDescription = new FLDDesc [ 3 ]; // first field description pFieldDescription [ 0 ] . iFldNum = 1; strcpy ( pFieldDescription [ 0 ] . szName, "MYFIELD_1" ); pFieldDescription [ 0 ] . iFldType = fldZSTRING; pFieldDescription [ 0 ] . iSubType = fldUNKNOWN; pFieldDescription [ 0 ] . iUnits1 = 8; pFieldDescription [ 0 ] . iUnits2 = 0; pFieldDescription [ 0 ] . iOffset = 0; pFieldDescription [ 0 ] . iLen = 0; pFieldDescription [ 0 ] . iNullOffset = 0; pFieldDescription [ 0 ] . efldvVchk = fldvNOCHECKS; pFieldDescription [ 0 ] . efldrRights = fldrREADWRITE; // second field description pFieldDescription [ 1 ] . iFldNum = 2; strcpy ( pFieldDescription [ 1 ] . szName, "MYFIELD_2" ); pFieldDescription [ 1 ] . iFldType = fldZSTRING; pFieldDescription [ 1 ] . iSubType = fldUNKNOWN; pFieldDescription [ 1 ] . iUnits1 = 6; pFieldDescription [ 1 ] . iUnits2 = 0; pFieldDescription [ 1 ] . iOffset = 0; pFieldDescription [ 1 ] . iLen = 0; pFieldDescription [ 1 ] . iNullOffset = 0; pFieldDescription [ 1 ] . efldvVchk = fldvNOCHECKS; pFieldDescription [ 1 ] . efldrRights = fldrREADWRITE; // third field description pFieldDescription [ 2 ] . iFldNum = 3; strcpy ( pFieldDescription [ 2 ] . szName, "MYFIELD_3" ); pFieldDescription [ 2 ] . iFldType = fldZSTRING; pFieldDescription [ 2 ] . iSubType = fldUNKNOWN; pFieldDescription [ 2 ] . iUnits1 = 12; pFieldDescription [ 2 ] . iUnits2 = 0; pFieldDescription [ 2 ] . iOffset = 0; pFieldDescription [ 2 ] . iLen = 0; pFieldDescription [ 2 ] . iNullOffset = 0; pFieldDescription [ 2 ] . efldvVchk = fldvNOCHECKS; pFieldDescription [ 2 ] . efldrRights = fldrREADWRITE; // prepare the description of the index; only one index, so only one // structure required, no need to declare an array of descriptions IDXDesc* pIndexDescription = new IDXDesc; int aiKeyFieldNum [ 1 ]; strcpy ( pIndexDescription -> szName, "MYINDEX_2.NDX" ); pIndexDescription -> iIndexId = 0; strcpy ( pIndexDescription -> szTagName, "" ); strcpy ( pIndexDescription -> szFormat, "" ); pIndexDescription -> bPrimary = false; pIndexDescription -> bUnique = false; pIndexDescription -> bDescending = false; pIndexDescription -> bMaintained = false; pIndexDescription -> bSubset = false; pIndexDescription -> bExpIdx = false; pIndexDescription -> iCost = 0; pIndexDescription -> iFldsInKey = 1; pIndexDescription -> iKeyLen = 0; pIndexDescription -> bOutofDate = false; pIndexDescription -> iKeyExpType = fldDBCHAR; aiKeyFieldNum [ 0 ] = 2; pIndexDescription -> aiKeyFld [ 0 ] = aiKeyFieldNum [ 0 ]; strcpy ( pIndexDescription -> szKeyExp, "" ); strcpy ( pIndexDescription -> szKeyCond, "" ); pIndexDescription -> bCaseInsensitive = false; pIndexDescription -> iBlockSize = 0; pIndexDescription -> iRestrNum = 0; // prepare the description of the table CRTblDesc* pTableDescription = new CRTblDesc; strcpy ( pTableDescription -> szTblName, "MYTABLE.DBF" ); strcpy ( pTableDescription -> szTblType, szDBASE ); strcpy ( pTableDescription -> szErrTblName, "" ); strcpy ( pTableDescription -> szUserName, "" ); strcpy ( pTableDescription -> szPassword, "" ); pTableDescription -> bProtected = FALSE; pTableDescription -> bPack = FALSE; pTableDescription -> iFldCount = 3; pTableDescription -> pecrFldOp = crNOOP; pTableDescription -> pfldDesc = pFieldDescription; pTableDescription -> iIdxCount = 1; pTableDescription -> pecrIdxOp = crNOOP; pTableDescription -> pidxDesc = pIndexDescription; pTableDescription -> iSecRecCount = 0; pTableDescription -> pecrSecOp = crNOOP; pTableDescription -> psecDesc = 0; // security descriptors pTableDescription -> iValChkCount = 0; pTableDescription -> pecrValChkOp = crNOOP; pTableDescription -> pvchkDesc = 0; // check descriptors pTableDescription -> iRintCount = 0; pTableDescription -> pecrRintOp = crNOOP; pTableDescription -> printDesc = 0; // referential integrity desc. pTableDescription -> iOptParams = 0; pTableDescription -> pfldOptParams = NULL; pTableDescription -> pOptData = NULL; // create table DBIEXEC ( DbiCreateTable ( hDB, TRUE, *pTableDescription ) ); // deallocate memory delete pTableDescription; delete [ ] aiKeyFieldNum; delete pIndexDescription; delete [ ] pFieldDescription;