These three utility classes provide object-oriented representations for C-style memory structures
(TStruct), DBF field definitions (TField), and DBF index definitions (TIndex). They are used
when working with low-level data structures, defining DBF schemas programmatically, or creating
index files from Harbour code.
TStruct - C Structure Builder
TStruct models a C-language structure in Harbour memory. It maintains a binary buffer and a
list of member definitions, allowing members to be added and accessed by name or position.
#include "FiveWin.ch"
function Main()
local oIdx
// Define an index on CUSTOMER.DBF by the CODE field
oIdx := TIndex():New( "CUSTOMER.DBF", "CODE_IDX", "CODE", "CODE", .F., .F., "Index by code" )
// Create the index file
oIdx:Create( "C:\data\" )
return nil
Notes
TStruct uses Harbour's NumToBin() / BinToNum() internally for buffer serialization. It supports member access by both numeric index and name (via error handler).
TField is primarily a data container and does not modify the DBF file itself. It is useful for programmatic schema construction and metadata management.
TIndex:Create() opens the DBF, executes the INDEX command, and closes the file. It supports both CDX (default) and NTX formats based on the cType member.