Field types and constants
The field types, the field definition format and the constants.
Field Types#
| Type Code | Description | Notes |
|---|---|---|
C | Character (string) | Fixed width, space-padded on the right |
N | Numeric | Stored as a formatted ASCII string |
F | Float | Like N but allows scientific notation |
D | Date | 8-char string in YYYYMMDD format |
L | Logical | Stored as T / F |
M | Memo | Variable-length text in .fpt file; transparent to caller |
G | General (OLE) | Same layout as M; text content supported |
I | Integer | 4-byte little-endian binary |
B | Binary | Zero-initialised on append |
Field Definition Format#
When calling create(), each field is defined as a list with 3 or 4 elements:
[FieldName, TypeCode, Length, Decimals] # 4-element (full)
[FieldName, TypeCode, Length] # 3-element (decimals default to 0)- FieldName — up to 10 characters; automatically uppercased and truncated
- TypeCode — one of the type codes above; only the first character is used
- Length — storage width in bytes (ignored for
M/G, always forced to 4) - Decimals — number of decimal places for
N/Ffields
Constants Reference#
Version Flags#
The two flags the library writes when creating files:
C_DBF_VERSION_FOXPRO # 0x30 Visual FoxPro — no memo fields
C_DBF_VERSION_FOXPRO_MEMO # 0xF5 Visual FoxPro — has memo fieldsAdditional flags recognised when reading existing files:
C_DBF_VERSION_DBASE3 # 0x03
C_DBF_VERSION_DBASE3_MEMO # 0x83
C_DBF_VERSION_DBASE4_MEMO # 0x8BRecord Markers#
C_DBF_RECORD_ACTIVE # 0x20 space — record is active
C_DBF_RECORD_DELETED # 0x2A asterisk (*) — record is soft-deleted
C_DBF_EOF_MARKER # 0x1A end-of-file marker
C_DBF_HEADER_TERMINATOR # 0x0D end of field descriptor listField Sub-list Indices#
When working with the list returned by getStructure(), use these named indices instead of bare numbers:
FLD_NAME # 1 — field name string
FLD_TYPE # 2 — single-character type code
FLD_LEN # 3 — storage length in bytes
FLD_DEC # 4 — decimal places
FLD_OFFSET # 5 — byte offset within the record (internal use)