<< Click to Display Table of Contents >> Navigation: Apollo API (Apollo Engine) > Table Creation Example with Enhanced Field Types |
You may still use the traditional Date (D) and Numeric (N) fields as usual. To use the enhanced storage dates and numerics, you define them a little bit differently in your table creation routines. Specifically, the difference is in the parameters passed to the sx_CreateField function.
You normally create a table with sx_CreateNew followed by a series of calls to sx_CreateField, and finally with a call to sx_CreateExec. This general procedure remains unchanged. Here is sample source code that creates a table that includes both traditional and enhanced fields:
VB Example
sx_CreateNew( "TEST.DBF", "TEST", SDEFOX, 5 )
sx_CreateField( "LASTNAME", "C", 20, 0 ) ' Normal Char
sx_CreateField( "AGE", "N", 2, 0 ) ' Normal Numeric
sx_CreateField( "HIREDATE", "D", 8, 0 ) ' Normal Date
sx_CreateField( "SDATE", "D", 3, 0 ) ' Enhanced Date
sx_CreateField( "SALARY", "I", 4, 0 ) ' Enhanced Numeric
sx_CreateExec
C Example
sx_CreateNew( (BYTEP) "TEST.DBF", "TEST", SDEFOX, 5 )
sx_CreateField( (BYTEP) "LASTNAME", (BYTEP) "C", 20, 0 ) // Normal Char
sx_CreateField( (BYTEP) "AGE", (BYTEP) "N", 2, 0 ) // Normal Numeric
sx_CreateField( (BYTEP) "HIREDATE", (BYTEP) "D", 8, 0 ) // Normal Date
sx_CreateField( (BYTEP) "SDATE", (BYTEP) "D", 3, 0 ) // Enhanced Date
sx_CreateField( (BYTEP) "SALARY", (BYTEP) "I", 4, 0 ) // Enhanced Numeric
sx_CreateExec();
Enhanced Dates
Traditional DATE fields are always of length 8. To create an enhanced Date field, you declare the field with a length of 3. These are the only two acceptable options for the length parameter when declaring a DATE field.
Enhanced Numerics
To use the compressed integer storage mechanism of enhanced numeric fields, declare a field of type 'I' with length of 4. Type 'I' fields must always be declared with the length parameter of 4.