Create a database file (a dbf) from a database structure array.
<cFileName> is the name of the database file to be created. If an extension is not specified, .dbf is assumed.
<aStruct> is an array that contains the structure of database as a series of sub-arrays, one per field. Each sub-array contains the definition of each field's attributes and has the following structure:
Position |
Metasymbol |
Dbstruct.ch |
1 |
cName |
DBS_NAME |
2 |
cType |
DBS_TYPE |
3 |
nLength |
DBS_LEN |
4 |
nDecimals |
DBS_DEC |
<cRDD> specifies the replaceable database driver (RDD) to use, specified as a character expression. If not specified DBFNTX is used.
4-th argument <lKeepOpen> is Boolean flag indicating if file should stay open (any Boolean value will enable this behavior). 5-th is alias and if not given then the work area will stay open but without any alias, not even the filename of created database (this is a notably different behavior than what happens when USE command or dbUseaArea() function are invoked, where if no alias provided, by default, the name of database file is used as alias).
Note 1: the dbCreate() function does not check for duplicate field names. It could perfectly create fields with the same name, without any warning, with all unpredictable consequences of such an action. Developer alone has the responsibility to not use the same field name twice.
Note 2: If <cRDD> is different than default DBFNTX, it must have been explicitly requested and linked (using a REQUEST statement in source code), before can it be used.
Note 3: Setting lKeepOpen to .f. is sometimes not respected. Instead specify .t., and an alias, than use dbCloseArea().