Index Overview
Chapter Updated 09/10/25
| Version | dBASE Relese | Supported Key Types | Supported Sort Order | Supported Formats | Deleted Records (Standard dBASE processing) |
|---|---|---|---|---|---|
| NDX | All dBASE versions | Character Numeric Date | Ascending only | Non Unique Unique |
Kept in index |
| MDX Version 2 | dBASE IV and greater | Character Numeric Date |
Ascending or Descending |
Non Unique Unique |
Kept in index unless excluded with filter .NOT. DELETED() |
| MDX Version 3 | dBASE 7 and greater | Character Numeric Date Long Double TimeStamp |
Ascending or Descending |
Non Unique Unique Distinct Primary Key |
Disinct and Primary tags exclude deleted records. Non unique and unique include deleted records unless filtered out. |
| Format | Description (Standard dBASE processing) |
|---|---|
| Non Unique | Index will support one or more duplicate key values. |
| Unique | If the table contains more than one record with the same key value, the table is updated with the record containing the duplicate key but the index (tag) only contains a reference to the first record in the file. |
| Distinct | Introduced with MDX V3. Allows only one record in the table per key value. Excludes deleted records. |
| Primary Key | Introduced with MDX V3. Allows only one record in the table per key value. Excludes deleted records. Only one primary key allowed ber table. |
| Mode | Description | Deleted Records | Index Tags defined as Unique | Node Recycling |
|---|---|---|---|---|
| XB_IX_DBASE_MODE | DBase compatibility mode | See above for standard deleted records processing. | See above for standard unique key proocessing. | None |
| XB_IX_XBASE_MODE | Enhanced index processing. | NDX and MDX Version 2, deleted records are removed from the index. | NDX and MDX Version 2, attempts to add record with a duplcate key generates an error. | MDX Version 2 and MDX Version 3, empty pages recycled. |
| Method | Description |
|---|---|
| xbCore::GetDefaultIxTagMode() | Get the default mode |
| xbCore::SetDefaultIxTagMode( XB_IX_DBASE_MODE || XB_IX_XBASE_MODE ) | Set the default mode. Call during program initialization. |
| xbIx::GetIxTagMode( void *vpTag ) | Get the mode for the specified tag |
| xbIx::SetIxTagMode( void *vpTag, XB_IX_DBASE_MODE || XB_IX_XBASE_MODE ) | Set the mode for the specified tag |
| File Type | Source | Max Tags Per File | Auto Opened | Sort Order | Unique Keys | Distinct Keys | Primary Key | Reclaimed Nodes | Filter Support | Status |
|---|---|---|---|---|---|---|---|---|---|---|
| NDX | dBASE | ASC only | ||||||||
| MDX V2 | dBASE | XB_IX_XBASE_MODE enabled |
||||||||
| MDX V3 | dBASE | XB_IX_XBASE_MODE enabled |
||||||||
| NTX | Clipper | |||||||||
| CDX | Fox Pro | |||||||||
| IDX | Fox Pro | |||||||||
| Method | Description |
|---|---|
| xbInt16 xbDbf::CheckTagIntegrity( xbInt16 iTagOpt, xbInt16 iOutputOpt ) | Checks a tag for missing or duplicate entries. Available if XB_DEBUG_SUPPORT is on. |
| xbInt16 xbDbf::CloseIndexFile( xbIx *pIx ) | Close an index file. Indices are automatically closed when the table is closed.
Not typically called in an application program. |
| xbInt16 xbDbf::CreateTag( const xbString &sIxType, const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverLay, xbIx **xbIxOut, void **vpTagOut ); | Create a new tag. |
| xbInt16 xbDbf::DeleteTag( const xbString &sIxType, const xbString &sName ) | Delete existing tag. |
| xbInt16 xbDbf::Find( xbString &sKey ) xbInt16 xbDbf::Find( const char *sKey ) xbInt16 xbDbf::Find( xbDate &dtKey ) xbInt16 xbDbf::Find( xbDouble &dKey ) | Find key value for the active tag. |
| xbIx * xbDbf::GetCurIx() const | Returns a pointer to the current index object. | xbString & xbDbf::GetCurIxType() const | Returns the current index type. | void * xbDbf::GetCurTag() const | Retrieve pointer to the current active tag. |
| const xbString & xbDbf::GetCurTagName() const | Returns the current tag name. | xbInt16 xbDbf::GetFirstKey() | Retrieve the first key for the active tag. |
| xbIxList * xbDbf::GetIxList() const | Returns a pointer to the list of active indices. |
| xbInt16 xbIx::GetIxTagMode( void *vpTag ) | Returns one of XB_IX_DBASE_MODE or XB_IX_XBASE_MODE |
| xbInt16 xbDbf::GetLastKey() | Retrieve the last key for the active tag. |
| xbInt16 xbDbf::GetNextKey() | Retrieve the next key for the active tag. |
| xbInt32 xbDbf::GetPhysicalIxCnt() const | Returns count of number of physical files opened for DBF table. |
| xbInt16 xbDbf::GetPrevKey() | Retrieve the previous key for the active tag. |
| xbLinkListNode | Returns pointer to linked list of open tags for the DBF file/table. |
| xbString &xbIx::GetType() const | Returns one of NDX, MDX or TDX. |
| xbInt16 xbDbf::OpenIndex( const xbString &sIxType, const xbString &sIndexName ) | Open an index file. Only used for index files that aren't automatically opened. |
| xbInt16 xbDbf::Reindex( xbInt16 iTagOpt ) | Rebuild a tag. Available if XB_DEBUG_SUPPORT is on. |
| xbInt16 xbDbf::SetCurTag( const xbString &sTagName ) void xbDbf::SetCurTag( const xbString &sIxType, xbIx *pIx, void *vpTag ) | Set current tag. |
| xbIx::SetIxTagMode( void *vpTag, XB_IX_DBASE_MODE || XB_IX_XBASE_MODE ) |
Set the processing mode for the specified tag. |
| Type | Stored in DBF as | Stored in NDX as | Stored in MDX V2 as | Stored in MDX V3 as |
|---|---|---|---|---|
| C | Character data | Character data | Character data | Character data |
| F | Text numbers | xbDouble | xbBcd | 12 byte xbBcd |
| N | Text numbers | xbDouble | xbBcd | 12 byte xbBcd |
| D | Text YYYYMMDD | xbDouble Julian | xbDouble Julian | 12 byte double julian |
| I | Long Int | N/A | N/A | 4 Byte Long |
| + | Auto Increment | N/A | N/A | 4 Byte Long |
| O | Double | N/A | N/A | 8 Byte Double |
| @ | Time Stamp | N/A | N/A | 8 Byte Time Stamp |
| Type | Size | Field Name | Description |
|---|---|---|---|
| xbLong | 4 | StartNode | This identifies the root node of the index. The Header node is node 0. |
| xbLong | 4 | Total Nodes | This is the count of the total nodes in the index. The count includes the header node. |
| xbLong | 4 | NoOfKeys | Total number of keys in the index +1 |
| xbUShort | 2 | KeyLen | The index key length |
| xbUShort | 2 | KeysPerNode | The maximum number of keys per node |
| xbUShort | 2 | KeyType | Type of key 00 - Character 01 - Numeric |
| xbLong | 4 | Keysize | Key record size + 8 |
| char | 1 | Unknown | Reserved |
| char | 1 | Unique | Unique indicator 00 - Not Unique - XB_NON_UNIQUE 01 - Unique - XB_UNIQUE |
| char | 488 | KeyExpression | Key expression string |
| 512 | Total bytes in node |
| Type | Size | Field Name | Description |
|---|---|---|---|
| xbLong | 4 | NoOfKeysThisNode | The number of key values in this node. |
| char | 508 | KeyRec | A repeating structure of pointers and keys. See the next table for the KeyRec structure. |
| Type | Size | Field Name | Description |
|---|---|---|---|
| xbLong | 4 | LeftNodeNo | The node number of the lower node for this key. 0 in Leaf Nodes. |
| xbLong | 4 | DbfRecNo | The DBF record number for this key. 0 in Interior Nodes. |
| char | KeyLen | KeyValue | The key value. |
