#### #### ######
 ##   ##  ##   ##
  ## ##   ##   ##  ######    ######   #####
   ###    ######        ##  ##       ##   ##
  ## ##   ##   ##  #######  ######## #######
 ##   ##  ##   ## ##    ##        ## ##
#### #### ######   ######## #######   #####

Xbase File Format Description
by
Erik Bachmann
Clickety Click Software
1999-03-08

WHAT IS XBASE

"Generic term for the dBASE family of database languages. Coined in response to threatened litigation over use of the copyrighted trademark 'dBASE'."
http://wombat.doc.ic.ac.uk/

Xbase is a complex of data files (.DBF), indexes (NDX, MDX, CDX etc.) and eventually note files (DBT) for storing large amounts of formatted data in a structured form.

The Xbase family of databases is covering the dBase, Clipper, FoxPro, and their Windows equivalents Visual dBase, Visual Objects, and Visual FoxPro, plus some older products. All are based on the .DBF file format.

Basically Xbase is three different types of files:

NN.dbf
Data files
NN.dbt
Memo files (i.e. a separate file containing full text fields)
*.ndx
Index files pointing to a field in the *.dbf
Xbase is almost compatible with dBASE and is actually a clone of dBASE. The creator of dBASE Ashton-Tate (and later Borland) has the copyright for the name dBASE, but NOT the structure.
Therefore the name Xbase (It smells like - but it's not :-) has been widely used for look-alike data structures.
There has been an attempt to create a standard for Xbase. I've found a lot of dead links while searching on Alta Vista's World Wide Web search engine.

I'm at the moment not aware of the result of the Xbase comity’s work.

Xbase has - like most dBASE clones - it's offspring in the dBASE III+ file structure. I've tried to add all later enhancements as notes to the structure.


Index


WHY THIS DOCUMENT

I've been looking for a simple database tool for my work with C programming and bibliographical database systems. During my investigation of a lot of BBS's, FTP sites, toolboxes etc. I've discovered at lot of almost-ready-to-fly Xbase clones. This made me wonder why noone has collected a description of Xbase files AND made a simple package of C functions to handle this type of data files.
THAT was my goal - and THIS is the result.


 .----.
((*)(*))
 \ /\ /
  #### 
  \__/
WARNING ! ! ! 
DO *NOT* 
attempt to manipulate any critical database files *WITHOUT* making a proper and validated backup first. 
DO *NOT* 
access any database files in a multi-user environment! 
DO *NOT*
access the files in text mode. Use binary mode only ! 

Any comments, corrections, additions etc. are welcome. You can reach me at: e_bachmann@hotmail.com
or by snail mail:

Erik Bachmann

Grydehøjvej 62
DK-4000 Roskilde
Denmark
Europe
Third stone from the Sun - and turn left :-)

Note! Mispelling an tybingerors are included for freee :-)


A few words of concern

Binary
Means data is stored in blocks of paired bytes each 8 bits in size. The bytes are swaped in pairs the Intel way with the low byte value first and the high byte value last:

ABCDEF (ASCII)
BADCFE (binary)
Garbage/Reserved
Some areas in the files are labeled garbage or reserved or not used. These areas might contain bits and pieces from old files. Check out these areas (and overwrite them with 00h).

You might not want to destribute an old love letter or - as I nearly did - parts of your check account.

WHAT SORT OF DATA CAN BE HANDLED

Data files (*.dbf) contains a header with information on the data structure AND the record themselves. The data field is predefined as carrying data of a specific type ( Character, Numbers, Longs, Dates, Memo).
Each data type has its limitations:
C Character ASCII text < 254 characters long. Character fields can be up to 32 KB long (in Clipper and FoxPro) using decimal count as high byte in field length. It's possible to use up to 64KB long fields by reading length as unsigned. 
N Number ASCII text 18 characters long. Number fields can be up to 20 characters long in FoxPro and Clipper. 
L Logical Boolean/byte (8 bit) Legal values:   
? Not initialised (default)  
Y,y Yes
N,n No
F,f False
T,t True
Logical fields are always displayed using T/F/?. Some sources claims that space (ASCII 20h) is valid for not initialised.   
D Date Date in format YYYYMMDD. A date like 0000-00- 00 is *NOT* valid. 
M Memo Pointer to ASCII text field in memo file 10 digits representing a pointer to a DBT block (default is blanks). 
F Floating point (dBASE IV and later, FoxPro, Clipper) 20 digits 
N/A Character name variable 1-254 characters (64 KB in FoxBase and Clipper) 
B Binary (dBASE V) Like Memo fields, but not for text processing. 

(FoxPro/FoxBase) Double integer *NOT* a memo field

G General (dBASE V: like Memo) OLE Objects in MS Windows versions 
P Picture (FoxPro) Like Memo fields, but not for text processing. 
Y Currency (FoxPro)
T DateTime (FoxPro)
I 4 byte little endian integer (FoxPro)
Index files (*.ndx) are sorted references to fields in the data files. There might be more than one index for each data file.

dBASE III Memo files are primitive 512 byte hunks of ASCII text data creating a way for text fields to exceed the 255 characters barrier of ordinary text fields. Other versions may store up till 64 KB of text in a fixed sized text field. Larger amounts of text (and binary data) is still stored in memo-like files. The size off the blocks can be user defined while creating the memo file (see byte 4-7 of the memo file structure).
 .----.
((*)(*))
 \ /\ /
  #### 
  \__/
Note that memo fields are not fully supported by a majority of Xbase utilities (incl. dBASE III). You can't export/import records with memo fields (They are ignored in delimited exports in dBASE III). 
To avoid problems with the priority of fields, put memo fields at the very end of the record.



WHAT DO THE FILES LOOK LIKE

They all look brown to me :-) 
All Xbase files have a header describing the structure of the data in the file.

Schematically they look like this:

The structure of data files (*.dbf)

    _______________________  _______
 0 | Version number      *1|  ^
   |-----------------------|  |      
 1 | Date of last update   |  |
 2 |      YYMMDD           |  |
 3 |                       |  |
   |-----------------------|  |
 4 | Number of records     | Record
 5 | in data file          | header
 6 | ( 32 bits ) *14       |  |
 7 |                       |  |
   |-----------------------|  |
 8 | Length of header      |  |
 9 | structure ( 16 bits ) |  |
   |-----------------------|  |
 10| Length of each record |  |
 11| ( 16 bits )         *2|  |
   |-----------------------|  |
 12| ( Reserved )        *3|  |
 13|                       |  |
   |-----------------------|  |
 14| Incomplete transac.*12|  |
   |-----------------------|  |
 15| Encryption flag    *13|  |
   |-----------------------|  |
 16| Free record thread    |  |
 17| (reserved for LAN     |  |
 18|  only )               |  |
 19|                       |  |
   |-----------------------|  |
 20| ( Reserved for        |  |            _  |=======================| ______
   |   multi-user dBASE )  |  |           /  0| Field name in ASCII   |  ^ 
   : ( dBASE III+ - )      :  |          /    : (terminated by 00h)   :  |
   :                       :  |         |     |                       |  |
 27|                       |  |         |   10|                       |  |
   |-----------------------|  |         |     |-----------------------| For
 28| MDX flag (dBASE IV) *4|  |         |   11| Field type in ASCII   | each
   |-----------------------|  |         |     |-----------------------| field
 29| Language driver     *5|  |        /    12| Field data address    |  |
   |-----------------------|  |       /       |                     *6|  |
 30| ( Reserved )          |  |      /        | (in memory !!!)       |  |
 31|                     *3|  |     /       15| (dBASE III+)          |  |
   |=======================|__|____/          |-----------------------|  | <-
 32|                       |  |  ^          16| Field length  (binary)|  |   |
   |- - - - - - - - - - - -|  |  |            |-----------------------|  |   | *7
   |                       |  |  |          17| Decimal count (binary)|  |   |
   |- - - - - - - - - - - -|  |  Field        |-----------------------|  | <-
   |                       |  | Descriptor  18| ( Reserved for        |  |
   :. . . . . . . . . . . .:  |  |array     19|   multi-user dBASE)*18|  |
   :                       :  |  |            |-----------------------|  |
n  |                       |__|__v_         20| Work area ID      *16 |  |
   |-----------------------|  |    \          |-----------------------|  |
n+1| Terminator (0Dh)      |  |     \       21| ( Reserved for        |  |
   |=======================|  |      \      22|   multi-user dBASE )  |  |
m  | Database Container    |  |       \       |-----------------------|  |
   :                *15    :  |        \    23| Flag for SET FIELDS   |  |
   :                       :  |         |     |-----------------------|  |
m+263                      |  |         |   24| ( Reserved )          |  |
   |=======================|__v_ ___    |     :                       :  |
   :                       :    ^       |     :                       :  |
   :                       :    |       |   30|                       |  |
   | Record structure      |    |       |     |-----------------------|  |
   |                       |    |        \  31| Index field flag    *8|  |
   |                       |    |         \_  |=======================| _v_____
   |                       | Records
   |-----------------------|    |                                      
   |                       |    |          _  |=======================| _______
   |                       |    |         /  0| Field deleted flag  *9|  ^ 
   |                       |    |        /    |-----------------------|  |
   |                       |    |       /     | Data               *10|  One
   |                       |    |      /      :                    *17: record
   |                       |____|_____/       |                       |  |
   :                       :    |             |                       | _v_____
   :                       :____|_____        |=======================|
   :                       :    |     \       | Field deleted flag  *9|
   |                       |    |      \      |-----------------------|
   |                       |    |       \     |                       |
   |                       |    |        \    |                       |
   |                       |    |         \_  |-----------------------|
   |                       |    |
   |=======================|    |
   |__End_of_File__________| ___v____  End of file ( 1Ah )  *11
*1
dBASE III+:

Also called signature.
02h
FoxBase.
03h
File without DBT.
30h
Visual FoxPro
83h
File with DBT. i.e. bit 0-3 version, 3-5 SQL, 7 DBT flag
dBASE IV:
bit
0-2
Version no.
3
Presence of memo file
4-6
Presence of SQL table
7
DBT flag
Examples:
03h
dBASE III w/o memo file
04h
dBASE IV or IV w/o memo file
05h
dBASE V w/o memo file
83h
dBASE III+ with memo file
F5h
FoxPro w. memo file
8Bh
dBASE IV w. memo
8Eh
dBASE IV w. SQL table
30h
Visual FoxPro w. DBC
7Bh
dBASE IV with memo
*2
Sum of lengths of all fields + 1 (deletion flag)
*3
(dBASE IV) Filled with 00h.
*4
(dBASE IV) Production index / Multiple index file
01h
MDX file present
00h
no MDX file (index upon demand).
(FoxBase)
01h
CDX compound index file present,
00h
no CDX file.
(Visual FoxPro)
02h
With memo
04h
Database Container (DBC)
07h
DBC (incl. memo & indexes)
*5
(Foxpro) Code page:
01h DOS USA code page 437
02h DOS Multilingual code page 850
03h Windows ANSI code page 1251
C8h Windows EE code page 1250
64h EE MS-DOS code page 852
66h Russian MS-DOS code page 866
65h Nordic MS-DOS code page 865
 
*6
(FoxPro) 12-13. offset of field from beginning of record.

The field addresss is irellevant for other applications.
*7
(FoxPro, Clipper)

16-17: Field length for non-numerical fields. Byte 16 is normally field length (0-255) and byte 17 represents the high byte for field length (256-65535).
*8
(dBASE IV) Index field flag:
00h
No key for this field (ignored)
01h
Key exists for this field (in MDX)
*9
2Ah (*)
Record is deleted
20h (blank)
Record is valid
*10
There are no field separators for record terminators.
*11
dBASE II regards any End-of-File 1Ah value as the end of the file. dBASE III regard an End-of-File as an ordinary character, however it appends an extra End-of-File character at the physical end of the file.

If the file is packed the physical size of the file may be larger than the logical i.e. there may be garbage after the EOF mark
*12
(dBASE IV) Incomplete transaction 00h Transaction ended (or rolled back) 01h Transaction started
*13
(dBASE IV) Encryption flag 00h Not encrypted 01h Data encrypted
*14
Stored at binary i.e. value is generated as: byte#1 + (byte#2 * 256) + (byte#3 * 256²) + (byte#4 * 256³) .......
*15
(Visual FoxPro) Database Container (DBC) 263 bytes for backlist. Included in header structure.
*16
Work area ID is 01h in all dBASE III files
*17
An empty memo field has a reference filled with 10 blanks.
*18
(FoxPro/FoxBase) Field Flags:
01h
System column (not visible to user)
02h
Column can store null values
04h
Binary colunn (for CHAR and MEMO only)


What to check when opening a .DBF File

Records:

Fields:

File size:


The Structure of Index files (.ndx)

The index file is a B+ tree - at least according to most description - but it's more clearly decribed as a paged B-tree.
The essential structure is in an inverted tree, with an anchor note, multiple root nodes, and leaf nodes. The header is called the anchor node.


 ____
/    \
\    /
 \  /
  \/
 |__|
Normally the header is read once only by the application, when the file is opened. 

The size of a page is ( as far as I know ) always 512 bytes.

    _______________________  _______
 0 | Starting page no      |  ^
 1 |                   *1  |  |
 2 |                       |  |
 3 |                       |  |
   |-----------------------|  |
 4 | Total no of pages     | File
 5 |                       | header
 6 |                       |  |
 7 |                       | (page 0)
   |-----------------------|  |
 8 | (Reserved)            |  |
 9 |                       |  |
10 |                       |  |
11 |                       |  |
   |-----------------------|  |
12 | Key length            |  |
13 |                       |  |
   |-----------------------|  |
14 | No of keys per page   |  |
15 |                       |  |
   |-----------------------|  |
16 | Key type: 0 = char    |  |
17 |           1 = Num     |  |
   |-----------------------|  |
18 | Size of key record  *2|  |
19 |                       |  |

20 |                       |  |
21 |                       |  |
   |-----------------------|  |
22 | (Reserved)            |  |
   |-----------------------|  |
23 | Unique flag           |  |
   |-----------------------|  |
24 | String defining the   |  |
   | key                   |  |
   :                       :  |
   :                       :  |
   :                       :  |
511|                       |  |
   |=======================| _v____
  0| No of valid entries   |  ^           __  |=======================|
  1| on current page       |  |          /   0| Pointer to lower level|
  2|                       |  |         /    1| (next page)           |
  3|                       |  |        /     2|                       |
   |-----------------------|  |       /      3|                       |
  4|                       |  |      /        |-----------------------|
   | Array of key entries  | _|_____/        4| Record number in      |
   |                       |  |              5| data file             |
   |                       | Page            6|                       |
   |                       |  |              7|                       |
   |                       |  |               |-----------------------|
   |                       | _|_____         8| Key data  *3          |
   :.......................:  |     \         :                       :
   :.......................:  |      \       N|                       |
511|                       |  |       \_____  |=======================|
   |=======================| _v_____
  0|                       |  |
   | No of valid entries   |  |
   | on current page       |  |
  3|                       | Page
   |-----------------------|  |
   | Array of key entries  |  |
   :.......................:  |
   :.......................:  |
511|:                      |  |
   |=======================| _v_____
*1
Root page number's offset is: page number * 512 bytes
*2
Size of key record is a multiplum of 4. Record size is 4 (Pointer to next page) + 4 (record number i dbf) + key size ( as a multiplum of 4 ). i.e. if the key size is 10, the record size is 20 (4+4+12)
*3
Numbers are stored as IEEE doubles (binary values).

Search algorithm for index files

  1. The anchor node always resides in memory, while the file is open and determines which root node to access for at given key.
  2. The root node is read and sequentially scanned until a key is found that is >= to the desired key.
  3. A second-level node is accessed and scanned in a manner similar to the root node.
  4. The process continues until the pointer to the next-lower-level node has a value of zero. If the key matches the leaf key at this level, the record number for the key is returned.

  5. That's a discipline NOT to be discussed here :-) Way out of the scope fore this document and way too complex.

One of the advances of the B+ tree is that the higher levels of the tree does not have to be updated when a certain node is changed - unless the tree has become unbalanced.
 ____
/    \
\    /
 \  /
  \/
 |__|
If the data or index files are corrupt you may get a "DISK FULL" error. The program can not read the EOF marker and therefore assumes that the disk is full. Check you file and make sure there is no garbage in it, also re-index your files. 



The Structure of Multiple Index files (*.mdx)


    _______________________  _______
 0 | Version number      *1|  ^
   |-----------------------|  |      
 1 | Date of creation      |  |
 2 |      YYMMDD           |  |
 3 |                       |  |
   |-----------------------|  |
 4 | Data file name        | File
 5 | (no extension)        | Header
   :                       :  |
   :                       :  |
19 |                       |  |
   |-----------------------|  |
20 | Block size            |  |
   |                       |  |
   |-----------------------|  |
22 | Block size adder N    |  |
   |                       |  |
   |-----------------------|  |
24 | Production index flag |  |
   |-----------------------|  |
25 | No. of entries in tag |  | *2
   |-----------------------|  |
26 | Length of tag         |  | *3
   |-----------------------|  |
27 | (Reserved)            |  |
   |-----------------------|  |
28 | No.of tags in use     |  |
   |                       |  |
   |-----------------------|  |
30 | (Reserved)            |  |
   |                       |  |
   |-----------------------|  |
32 | No.of pages in tagfile|  |
   |                       |  |
   |                       |  |
35 |                       |  |
   |-----------------------|  |
36 | Pointer to first free |  |
   | page                  |  |
   |                       |  |
39 |                       |  |
   |-----------------------|  |
40 | No.of block available |  |
   |                       |  |
   |                       |  |
43 |                       |  |
   |-----------------------|  |
44 | Date of last update   |  |
   |      YYMMDD           |  |
46 |                       |  |
   |-----------------------|  |
47 | (Reserved)            |  |
   |-----------------------|  |
48 | (Garbage)             |  |
   :                       :  |
   :                       :  |
   |                       |  |        ___|=======================|
543|                       | _V___    / 0 | Tag header page no.   |
   |-----------------------|  |      /    |                       |
544| Tag table entries     | Tag    /     |                       |
   |                       | Table |    3 |                       |
   :.......................:  |    |      |-----------------------| Tag
   :                       :  |    |    4 | Tag name              | table
   :.......................:  |    |      :                       :
   :                       :  |   /       :                       :
   :                       :  |  /        |                       |
   :.......................:__|_/      14 |                       |
   :                       :  |           |-----------------------|
   :                       :  |        15 | Key format         *4 |
   :                       :  |           |-----------------------|
   :.......................:__|_       16 | Forward tag thread (<)|
   :                       :  | \         |-----------------------|
   :                       :  |  \     17 | Forward tag thread (>)|
   :                       :  |   \       |-----------------------|
   :                       :  |    |   18 | Backward tag thread *5|
   |                       |  |    |      |-----------------------|
   |                       |  |    |   19 | (Reserved)            |
M*N|                       |__V__  |      |-----------------------|
   |=======================|  ^    |   20 | Key type           *6 |       
  0| Pointer to root page  |  |    |      |-----------------------|
   |                       |  |    |   21 | (Reserved)            |
   |                       |  |    |      :                       :
  3|                       |  |    |      :                       :
   |-----------------------|  |    |   31 |                       |
  4| File size in pages    | Tag   |      |-----------------------|
   |                       | header|   32 | (Garbage)             |
   |                       |  |    |      :                       :
  7|                       |  |    |      |                       |
   |-----------------------|  |     \  N  |                       |
  8| Key format         *7 |  |      \____|=======================|
   |-----------------------|  |
  9| Key type           *8 |  |
   |-----------------------|  |
 10| (Reserved)            |  |
   |                       |  |
   |-----------------------|  |
 12| Index key length   *9 |  |
   |                       |  |
   |-----------------------|  |
 14| Max.no.of keys/page   |  |
   |                       |  |
   |-----------------------|  |
 16| Secondary key type *10|  |
   |                       |  |
   |-----------------------|  |
 18| Index key item length |  |
   |                       |  |
   |-----------------------|  |
 20| (Reserved)            |  |
   |                       |  |
   |                       |  |
   |-----------------------|  |
 23| Unique flag           |  |
   |-----------------------|  |
   |                       |  |
   :                       :  |
   :                       :__V__
N*M|=======================|
1
2
Number of entries in tag table. Max no. is 48 (30h)
3
Length of each tag table entry. Max is 32 (20h).
4
00h
Calculated
10h
Data field
5
Previous tag
6
C
Character
N
Numerical
D
Date
7
00h
Right, left, dtoc
08h
Decending order
10h
Fields , string
40h
Unique keys
8
C
Character
N
Numerical
D
Date
9
Numeric
Length is 12
Date
Length is 8
Character
Length is <= 100 bytes and not NULL terminated
10
0
Character/numerical (db4), Character (db3)
1
Date (db4) Numerical/date (db3)



The Structure of Compound Index files (*.cdx)

by David Kuechler (71202.1315@CompuServe.COM)

A CDX is a compact IDX. The initial IDX contains one key per tag. The key is 10 byte character string which is the tag name. The record number stored with the key is the offset to the root page for that tag.
 ____
/    \
\    /
 \  /
  \/
 |__|
There is no description on the compression algorithm 
A compact IDX has the following structure:

    _______________________  _______
  0 | Pointer to root node  |  ^
  1 |                       |  |
  2 |                       |  |
  3 |                       |  |
    |-----------------------|  |
  4 | Pointer to free list  | File
  5 | (-1 if empty)         | header
  6 |                       |  |
  7 |                  *8   | (page 0)
    |-----------------------|  |
  8 | Version no.      *10  |  |
  9 |                       |  |
 10 |                       |  |
 11 |                       |  |
    |-----------------------|  |
 12 | Key length            |  |
 13 |                  *9   |  |
    |-----------------------|  |
 14 | Index options *1      |  |
    |-----------------------|  |
 15 | Index Signature       |  |
    |-----------------------|  |
 16 | (Reserved)            |  |
 17 |                       |  |
    : (Currently all NULL's):  |
    :                       :  |
    :                       :  |
 501|                       |  |
    |-----------------------|  |
 502| Sort order *2         |  |
 503|                       |  |
    |-----------------------|  |
 504| Total expression      |  |
 505| length (FoxPro 2)     |  |
    |-----------------------|  |
 506| FOR expression length |  |
 507| (binary)              |  |
    |-----------------------|  |
 508| (Reserved)            |  |
 509|                       |  |
    |-----------------------|  |
 510| Key expression length |  |
 511| (binary)              |  |
    |=======================| _v____
 512| Key & FOR expression  |  ^
 513|            *3         |  |
    :                       :  |
    :                       :  |
1023|                       |  |
    |=======================| _v____
  0 | Node attributes *4    |  ^
  1 |                       |  |
    |-----------------------|  |
  2 | Number of keys        |  |
  3 |                       |  |
    |-----------------------| Non
  4 | Pointer to left       | leaf
  5 | brother node          | page
  6 | (-1 if no left node)  |  |
  7 |                       | (compressed)
    |-----------------------|  |
  8 | Pointer to right      |  |
  9 | brother node          |  |
 10 | (-1 if no right node) |  |
 11 |                       |  |
    |-----------------------|  |
 12 |                       |  |
    |                       |  |           __  |=======================|
    |                       |  |          /    | Key data              |
    |                       | NON        /     :                       :
    |                       | leaf      /      :                       :
    |                       | page     /       |                       |
    |                       |  |      /        |-----------------------|
    | Array of key entries  | _|_____/        M| Record number in      |
    |                       |  |               | data file             |
    |                       |  |               | (high order byte      |
    |                       |  |              N|  first)               |
    |                       |  |               |-----------------------|
    |                       | _|_____         m| Pointer to child page |
    :.......................:  |     \         |                       |
    :.......................:  |      \        |                       |
    :.......................:  |       \      n|                       |
 511|                       |  |        \____  |=======================|
    |=======================| _v_____
  0 | Node attributes *4    |  ^
  1 |                       |  |
    |-----------------------|  |
  2 | Number of keys        |  |
  3 |                       |  |
    |-----------------------|  |
  4 | Pointer to left       | Leaf
  5 | brother node          | page
  6 | (-1 if no left node)  |  |
  7 |                       | (compressed)
    |-----------------------|  |
  8 | Pointer to right      |  |
  9 | brother node          |  |
 10 | (-1 if no right node) |  |
 11 |                       |  |
    |-----------------------|  |
 12 | Free space available  |  |
 13 | in page               |  |
    |-----------------------|  |
 14 | Record number mask    |  |
 15 |                       |  |
 16 |                       |  |
 17 |                       |  |
    |-----------------------|  |
 18 | Duplicate count mask  |  |  *11
    |-----------------------|  |
 19 | Trailing byte count mask |  *11
    |-----------------------|  |
 20 |*5 record no           |  |
    |-----------------------|  |
 21 |*5 duplicate count     |  |
    |-----------------------|  ^           __  |=======================|
 22 |*5 trailing count      |  |          /   0| Recno/supCount/       |
    |-----------------------| Leaf       /    1| TrailCount            |
 23 |*6 holding record no   | page      /     2| *7)                   |
    |-----------------------|  |       /      3|                       |
 24 |                       |  |      /        |-----------------------|
    | Array of key entries  | _|_____/        4| Record number in      |
    |                       |  |              5| data file             |
    |                       |  |              6|                       |
    |                       |  |              7|                       |
    |                       |  |               |-----------------------|
    |                       | _|_____         8| Key data              |
    :.......................:  |     \         :                       :
    :.......................:  |      \       N|                       |
 511|                       |  |       \_____  |=======================|
    |=======================| _v_____
*1)
Index options represented as the sum of the following values:
01
Unique index
08
FOR clause
16 (10h)
Bit vector (SoftC)
32 (20h)
Compact index format (FoxPro)
64 (40h)
Compounding index header (FoxPro)
128 (80h)
Structure index (FoxPro)
*2)
0
Ascending
1
Descending
*3)
Key first with null terminator, then FOR expression.
4)
Node attributes represented as the sum of the following values:
0
Interior node (branch)
1
Root page
2
Leaf page
5)
Byte 020
Number of bits for record number
Byte 021
Number of bits for duplicate count
Byte 022
Number of bits for trailing count
6)
Byte 023:
Number of bytes holding record number, duplicate count & trailing count (i.e. the total size of values in byte 20 - 22).
7)
At the start of this area, the recno/dupCount/trailCount is stored (bit compressed). Each entry requires the number of bytes as indicated by byte 023.

The key values are placed at the end of this area (working backwards) and are stored by eliminating any duplicates with the previous key and any trailing blanks.

8)
-1
if none (FoxPro)
0
if none (FoxBase)
9)
Number and date keys are 8 bits long . Character keys are <= 100 bytes long.

Note! Character keys are NOT terminated with 00h
-1
if none (FoxPro)
0
if none (FoxBase)
10)
(Foxbase, FoxPro 1.x) No. of pages in file.

(FoxPro 2.x) Reserved.
11)
The individual list must be ANDed with these masks in order to calculate the original index.

Other Notes on CDX

Dates are stored as Julian dates and converted to numbers

Numbers are stored as IEEE doubles (binary values) with the following conversion:

The advantage of this storage format is it allows numbers to be compared directly using memcmp(). 



The Structure of Uncompressed Index files (*.idx)

    _______________________  _______
  0 | Pointer to root node  |  ^
  1 |                       |  |
  2 |                       |  |
  3 |                       |  |
    |-----------------------|  |
  4 | Pointer to free list  | File
  5 | (-1 if empty)         | header
  6 |                       |  |
  7 |                  *3   | (page 0)
    |-----------------------|  |
  8 | Pointer to EOF        |  |
  9 |                       |  |
 10 |                       |  |
 11 |                       |  |
    |-----------------------|  |
 12 | Key length            |  |
 13 |                  *4   |  |
    |-----------------------|  |
 14 | Index options *1      |  |
    |-----------------------|  |
 15 | Index Signature       |  |
    |-----------------------|  |
 16 | Key expression        |  |
 17 |                       |  |
    :                       :  |
    :                       :  |
 235|                       |  |
    |-----------------------|  |
 236| FOR expression        |  |
    |                       |  |
    :                       :  |
    :                       :  |
 455|                       |  |
    |-----------------------|  |
 456| (Reserved)            |  |
    |                       |  |
    :                       :  |
    :                       :  |
 511|                       |  |
    |=======================| _v____
  0 | Node attributes *2    |  ^
  1 |                       |  |
    |-----------------------|  |
  2 | Number of keys        |  |
  3 |                       |  |
    |-----------------------| Non
  4 | Pointer to left       | leaf
  5 | brother node          | page
  6 | (-1 if no left node)  |  |
  7 |                       | (compressed)
    |-----------------------|  |
  8 | Pointer to right      |  |
  9 | brother node          |  |
 10 | (-1 if no right node) |  |
 11 |                       |  |
    |-----------------------|  |
 12 |                       |  |
    |                       |  |           __  |=======================|
    |                       |  |          /   M| Key data              |
    |                       | NON        /     :                       :
    :                       : leaf      /      :                       :
    :                       : page     /      N|                       |
    :                       :  |      /        |-----------------------|
    | Array of key entries  | _|_____/        O| Record number in      |
    |                       | _|______         | data file             |
    |                       |  |      \        | (high order byte      |
    |                       |  |       \    O+4|  first)               |
 511|                       |  |        \____  |=======================|
    |=======================| _v_____
*1)
Index options represented as the sum of the following values:
01
Unique index
08
FOR clause
16 (10h)
Bit vector (SoftC)
32 (20h)
Compact index format (FoxPro)
64 (40h)
Compounding index header (FoxPro)
128 (80h)
Structure index (FoxPro)
2)
Node attributes represented as the sum of the following values:
0
Index node
1
Start page
2
End page
3)
-1
if none (FoxPro)
0
if none (FoxBase)
4)
Number and date keys are 8 bits long . Character keys are <= 100 bytes long.

Note! Character keys are NOT terminated with 00h
-1
if none (FoxPro)
0
if none (FoxBase)

The Structure of Clipper Index files (*.ntx)

The CA-Clipper index file is a modified B+ tree. The size of a page is 1024 bytes. The first page is the header:

     _______________________  _______
 0  | Signature byte        |  ^
 1  | (binary)              |  | *9
    |-----------------------|  |
 2  | Indexing version no.  |  |
 3  | (Compiler version)    |  |
    |-----------------------|  |
 4  | Offset in file for    | File
 5  | first index page.     | header
 6  | (root)                |  |
 7  |                       | (page 0)
    |-----------------------|  |
 8  | Offset to an unused   |  | *11
 9  | next key page.        |  |
10  |                       |  |
11  |                       |  |
    |-----------------------|  |
12  | Key size + 8 bytes    |  | *1
13  |                       |  |
    |-----------------------|  |
14  | Key size              |  |
15  |                       |  |
    |-----------------------|  |
16  | No. of decimals in    |  |
17  | key                   |  |
    |-----------------------|  |
18  | Max. item             |  | *6
19  |                       |  |
    |-----------------------|  |
20  | Half page             |  | *7
21  |                       |  |
    |-----------------------|  |
22  | Key expression.       |  | *8
23  | (NULL terminated)     |  |
    :                       :  |
277 |                       |  |
    |-----------------------|  |
278 | Unique index flag     |  | *3
    |-----------------------|  |
279 | (Unused)              |  |
    :                       :  |
    :                       :  |
1023|                       |  |
    |=======================| _v_____
   0| Address of next empty |    ^
   1| page *11              |    |
   2|                       |    |
   3|                       |    |
    |-----------------------|   Empty page
    : (Reserved)            |   (in linked list)
    :                       |    |
    :                       |    |
1023:                       |    |
    |=======================| ___V___
    | No. of used entries   |    |
    | on current page (N)   |    |
    |-----------------------|   Used
    | Array of N unsigned   |   page
    : longs   *5            :    |
    :                       :    |
    |-----------------------|    |
    | Array of index        |    |
    : entries               :    |
    :                       :    |         __  |=======================|
    :                       :    |        /   0| Address of left page  | *4
    |                       |    |       /    1| in tree               |
    |                       |    |      /     2|                       |
    |                       |    |     /      3|                       |
    |=======================| ___|____/        |-----------------------|
    |  Array of index       |    |            4| Record no. in DBF     |
    :                       :    |            5|                       |
    :                       :    |            6|                       |
    :                       :    |            7|                       |
    :                       :    |             |-----------------------|
    :                       :    |            8| Key field             |
    :                       : ___|____         :                       :
    |=======================|    |    \       N|                       |
    |                       |    |     \_____  |=======================|
    :                       :    |
    |__End_of_File__________| ___v____  End of file ( 1Ah )
*1
Distance between key pages. size + 2 longs.
*2
The first, or root page of an indes has a minimum of 1 entry regardless of this value.
*3
1
Unique
0
NOT unique
*4
This number will be between the minimum (half page) and maximum (max. item) defined in the header unless it is the root page.
*5
The array length is equal to the maximum number of key entries per page +1. Value 00h = No record. Other values: Record offset from start of page
*6)
The maximum number of keys (with their pointers) that can fit on an index page.
*7
The maximum number of keys that can fit on an index page, divided by two. This is an important value in a B-tree system as it is the minimum number of keys that must be on a page.
*8
The actual expression on which the index was built. It is a NULL terminated string with at max length of 256 bytes.
*9
0003h Clipper 87
0006h Clipper 5.x
*10
This is a reference to the first page in a linked list of empty pages in beteen valid data.
*11
Address 00 00 00 00h is the last empty page in chain.


The Structure of Memo Field Files (*.dbt)

dBASE III+

    _______________________  _______
 0 | Number of next        |  ^  ^
 1 | available block       |  |  |
 2 | for appending data    |  | Header
 3 | (binary)              |  |  |
   |-----------------------| _|__v__
 4 | ( Reserved )          |  |    
   |                       |  |
   |                       |  |
 7 |                       |  |
   |-----------------------|  |
 8 | ( Reserved )          |  |    
   :                       :  |
15 |                       |  |
   |-----------------------|  |
16 | Version no.  (03h)    |  |
   |-----------------------|  |
17 | (i.e. garbage)        |  |
   :                       : First block
   :                       :  |    
511|                       |  |    
   |=======================| _v_____
512|                       |  ^    
   |                       |  |
   |                       | 512 Bytes
   |                       | text blocks
   :                       :  |
   :                       :  |
   |                       |  |
   |-----------------------| _|_____
   | Field terminator (1Ah)|  |  ^
   |-----------------------|  |  |Terminating field
   | Field terminator (1Ah)|  |  |within the block *1
   |-----------------------| _|__v__
   : ( Unused )            :  |
1023                       :  |
   |=======================| _v_____
   |                       |  ^
   |                       |  |
   |                       | 512 Bytes
   |                       | text blocks
   :                       :  |
   :                       :  |
   |                       |  |
   |                       | _v_____
   |=======================|
*1)
(FoxPro, Fox??) Is reported to use only one field terminator (1Ah).
A memo field can be longer than the 512 byte block. It simply continues through the next block. The field is logically terminated by two End-of-file marks in the field. The reminder of the block is unused.
 ____
/    \
\    /
 \  /
  \/
 |__|
Every time you re-write a memo field to the memo file in dBASE the field is APPENDED to the memo file (i.e. the file expands for each update). dBASE V for DOS (and perhaps others) may reuse the space from the deleted text, if memo size <= allocated number of block in dbt file. 
The Memo file itself tells nothing about it's use. You need the corresponding DBF file to interpret the content of the memo file. Many of the clones and dBASE 5 have binary elements stored in the memo file marked with file type B or G.

dBASE IV

    _______________________
 0 | Number of next        |  ^
 1 | available block       |  |
 2 | for appending data    | Header
 3 | (binary)              |  |
   |-----------------------|  |
 4 | ( Reserved )          |  |    
   | Size of blocks     *1 |  |
   |                       |  |
 7 |                       |  |
   |-----------------------|  |
 8 | DBF file name         |  |    
   |                       |  |
   :                       :  |
15 |                       |  |
   |-----------------------|  |
16 | Reserved   (00h)      |  |
   |-----------------------|  |
17 | ( Reserved )          |  |
18 |                       |  |
19 |                       |  |
   |-----------------------|  |
20 | Block length          |  |
21 |                       |  |
   |-----------------------|  |
22 | ( Reserved )          |  |
   |                       |  |
   | (i.e. garbage)        |  |
   :                       :  |
   :                       :  |    
511|                       |  |    
   |=======================| _v_____
  1|                       |  ^                 Used block
   |                       |  ^           __  |=======================|
   |                       |  |          /   0| ( Reserved )          |
   :                       :  |         /    1|                       |
   :                       :  |        /     2|  FFh FFh 08h 00h      |
   |                       |  |       /      3|                       |
511|                       |  |      /        |-----------------------|
   |=======================| _|_____/        4| Length of memo field  |
  1|                       |  |              5|                       |
   :                       :  |              6|                       |
   :                       :  |              7|                       |
   |                       |  |               |-----------------------|
511|                       | _|_____         8| Memo data        *2   |
   |=======================|  |     \         :                       :
   |                       |  |      \       N|                       |
   |                       |  |       \_____  |=======================|
   |                       |  |
   |                       | 512 Bytes
   |                       | text blocks
   :                       :  |
   :                       :  |                 Unused block
   :                       :  |           __  |=======================|
   :                       :  |          /   0| Pointer to next free  |
   :                       :  |         /    1| block                 |
   :                       :  |        /     2|                       |
   |                       |  |       /      3|                       |
511|                       |  |      /        |-----------------------|
   |=======================| _|_____/        4| Pointer to next used  |
  1|                       |  |              5| block                 |
   :                       :  |              6|                       |
   :                       :  |              7|                       |
   |                       |  |               |-----------------------|
511|                       | _|_____         8| ( Reserved )          |
   |=======================|  |     \         :                       :
  1|                       |  |      \       N|                       |
   |                       |  |       \_____  |=======================|
   |                       |  |
   :                       :  |
   |                       |  |
   |-----------------------| _|_____
   | Field terminator (1Ah)|  |  ^
   |-----------------------|  |  |Terminating field
   | Field terminator (1Ah)|  |  |within the block *3
   |-----------------------| _|__v__
   : ( Unused )            :  |
511|                       :  |
   |=======================| _v_____
   |                       |  ^
   |                       |  |
   |                       | 512 Bytes
   |                       | text blocks
   :                       :  |
   :                       :  |
   |                       |  |
   |                       | _v_____
   |=======================|
*1)
(FoxBase, dBASE IV ??) Size of blocks in memo file (SET BLOCKSIZE). Default is 512 bytes.
*2)
End of text mark is 0Dh 0Ah and line breaks are 8Dh 0Ah
*3)
(FoxPro, Fox??) Is reported to use only one field terminator (1Ah).
A memo field can be longer than the 512 byte block. It simply continues through the next block. The field is logically terminated by two End-of-file marks in the field. The reminder of the block is unused.



 .----.
((*)(*))
 \ /\ /
  ####
  \__/
WARNING ! ! ! 
DO *NOT* 
attempt to treat these binary data as simple text ! ! ! 


The Structure of FoxPro Object and memo file (*.fpt)

The file format is used by Fox Pro 2.x and later The size of the header is 512 bytes

    _______________________  _______
 0 | Number of next        |  ^
 1 | available block       |  |
 2 | for appending data    | Header
 3 | (binary)           *1 |  |
   |-----------------------|  |
 4 | ( Reserved )          |  |    
 5 |                       |  |
   |-----------------------|  |
 6 | Size of blocks N   *1 |  |
 7 |                    *2 |  |
   |-----------------------|  |
 8 | ( Reserved )          |  |
   |                       |  |
   |                       |  |
   | (i.e. garbage)        |  |
   :                       :  |
   :                       :  |    
511|                       |  |    
   |=======================| _v_____
  1|                       |  ^                 Used block
   |                       |  |           __  |=======================|
   |                       |  |          /   0| Record type      *3   |
   :                       :  |         /    1|                       |
   :                       :  |        /     2|                       |
   |                       |  |       /      3|                       |
  N|                       |  |      /        |-----------------------|
   |=======================| _|_____/        4| Length of memo field  |
  1|                       |  |              5|                       |
   :                       :  |              6|                       |
   :                       :  |              7|                       |
   |                       |  |               |-----------------------|
  N|                       | _|_____         8| Memo data             |
   |=======================|  |     \         :                       :
   |                       |  |      \       N|                       |
   |                       |  |       \_____  |=======================|
   |                       |  |
   :                       :  |
  N|                       | _v_____
   |=======================|
*1)
Binary value with high byte first.
*2)
Size of blocks in memo file (SET BLOCKSIZE). Default is 512 bytes.
*3)
Record type
00h
Picture
01h
Memo
02h
Object
A memo field can be longer than the 512 byte block. It simply continues through the next block. The field is logically terminated by two End-of-file marks in the field. The reminder of the block is unused.




The Structure of Memmory Files (*.mem)

    _______________________  _______
 0 |                       |  ^
 1 | Variable name         |  |
   : terminated by 00h     : Header
 9 |                       |  |
10 |                       |  |
   |-----------------------|  |
11 | Variable type         |  |    
   |-----------------------|  |
12 | ( Reserved )          |  |
   :                       :  |
15 |                       |  |
   |-----------------------|  | <-
16 | Field length  (binary)|  |   |
   |-----------------------|  |   | *1
17 | Decimal count (binary)|  |   |
   |-----------------------|  | <-
18 | ( Reserved )          |  |
   :                       :  |
   :                       :  |
31 |                       | _v_____
   |-----------------------|  |      
32 | Variable              |  |
   :                       :  |
   :                       :__V_____
N  |=======================|
*1
(FoxPro, Clipper)

16-17: Field length for non-numerical fields. Byte 16 is normally field length (0-255) and byte 17 represents the high byte for field length (256-65535).


The Record Lock Field on a dBASE IV Table

In a DOS multiuser environment, each user can place record locks on a shared table. For example, if user JSMITH is editing record number 12 of Stock, user MBROWN cannot access that record until it is unlocked. This prohibits one user from unintentionally overwriting another user's work.

The dBASE table type gives you the Record Lock option to show you information about a locked record. If you check Record Lock, Database Desktop adds a hidden character field named _DBASELOCK to the table. This field shows you when a record was locked and by whom.
 ____
/    \
\    /
 \  /
  \/
 |__|
Although Database Desktop adds the Record Lock field to the table, you will not see it when you view the table. You see a record's Record Lock field only if you are locked out of that record. 
Use the Create dBASE Table dialogue box to create the Record Lock field for a dBASE table. Record Lock is not available for dBASE III+ tables.

The information you see when you find a locked field depends on the Info Size you specify. The Record Lock field can be from 8 to 24 characters. The default is 16.

0-1
The first two bytes (binary integer) tell whether a user has changed the record. Every committed change is counted encreasing the count by one.
2-4
The next three characters tell the time a user placed the lock. (10h 09h 07h i.e. 16:09:07)
5-7
The next three characters tell the date a user placed the lock. ( 60h 09h 0Bh i.e. (19)96-09-11 )
8-24
The remaining 16 characters are optional. They tell the name of the user that placed the lock.

The default size of 16 displays the changed status of the record, the time and date of the lock, and the first 8 characters of the user who placed the lock.

 ____
/    \
\    /
 \  /
  \/
 |__|
You cannot see from the locking info if the user releases the record again. You have to test the record locking. 
On DOS systems SHARE has to be loaded. Turbo C, DJGPP and compatible C compilers have functions like: 
lock() 
_dos_lock() 
locking() for setting locks on a region of a file 
and 
unlock() 
_dos_unlock() 
unlocking for removing the lock again. 
It's important that YOU remove the locks BEFORE closing the file. 


Read/write locks using share

by Phil Barnett (philb@iag.net)

Share holds the locks, but it doesn't know anything about the structure or program that is requesting the lock. All share does is record the lock offset, type (record or file) and file name with path and where (station) it came from, and remove it when the correct station requests removal.

Lets make a scenario.

You have a 1000 byte header on your dbf file, and each record is 99 bytes + one for the delete flag. (this is to make the math simple)

If you locked record one at the actual offset it would lock a range from byte 1001 to 1100.

Any other station requesting READ or WRITE would be denied. Of course, we can read through locks in xBase, so how do they do it?

The xBase languages add an arbitrary number to the actual offset. Originally, Clipper used 1,000,000,000 + record offset. Fox used another offset, and I am not sure but I think it was 4,000,000,000.

We'll call this huge number the Lock Offset.

Later, Clipper changed the Lock Offset to the same as Fox for certain RDD's. (.CDX and .IDX)

For years, even though Clipper could create .NDX indexes, it was not Lock Offset compatible with dBase, and using both platforms on the same data caused incorrect locking.

The Lock Offset numbers are arbitrarily large to keep actual data files from crossing the limit. (hopefully, we aren't creating any 1 trillion byte files) (or 4 trillion for newer schemes)

So, in an xBase file, record locks and writes are at Lock Offset + File Offset and reads are at File Offset, so they do not run into a lock. This allows "read through"

Locks between xBase systems are only able to be used concurrently when the arbitrary Lock Offset is the same in both systems.

So, in the above example, to lock the first record the Lock Offset would be 4,000,001,001 to 4,000,001,100.

If both languages used the same offset, then the write lock would be correctly enforced.


These offsets are mentioned in online documentation (for CA-Clipper) (read 52eint.txt or clip53a.txt). The 1,000,000+RECNO() is used as default. If you want to use offset 4,000,000 you have to link the ntxlock2.obj file. For CDX indexes you should link cdxlock.obj to be compatible with Fox locking scheme (but only for Clipper != 5.2e)
Confirmed by: r(ycho)GLAB, VIP Software (rglab@waw.pdi.net)

SoftC uses 0x4,000,000L for lock offset in FoxPro files


For more information on record locking read :
"Transactional Locking, Part 1" by Thomas Wang (wang@cup.hp.com) on
http://www.concentric.net/~Ttwang/tech/locks1.htm



How do I cope with the Year 2000 problem ?

In the header the date has the format YYMMDD which gives us the wonderful Year 2000 problem. Or does it ?

The 1st of february 1997 is written in the header as: 61h 02h 01h. If your computer can handle date *after* the year 1999 you'll find that, the 1st of february 2001 is written in the header as: 64h 02h 01h.

This means that the valid range for the year in the "last updated at" field in the dbf header is year 1900 - 2155 (value 00h to FFh + base year 1900).

All other fields containing dates has the format YYYYMMDD, which can handle all valid dates (so far :-)

Conclusion: Unless you care about data handling *after* the year 2155, the Xbase file formate should not impose any problems.


Check out: "New Year 2000 page on The Oasis" by Phil Barnett:


dBASE II FILES

The Structure of dBASE II data files (*.dbf)

    _______________________  _______
 0 | Version number      *1|  ^
   |-----------------------|  |      
 1 | Number of records     | Record
 2 | in data file (16 bit) | header
   |-----------------------|  |            _  |=======================| _______
 3 | Date of last update   |  |           /  0| Field name in ASCII   |  ^ 
 4 |      YYMMDD           |  |          /    : (terminated by 00h)   :  |
 5 |                       |  |         |     |                       |  |
   |-----------------------|  |         |   10|                       |  |
 6 | Length of each record |  |         |     |-----------------------| For
 7 | ( 16 bits )         *2|  |         |   11| Field type in ASCII *4| each
   |-----------------------|--|---      |     |-----------------------| field
 8 |                       |  |  ^      |   12| Field length  (binary)|  |
 9 | Field descriptor      |  |  | ____/      |-----------------------|  |
   : Array             *5  :  |  |          13| Field adress in memory|  |
   : (Terminated by 0Dh)   :  |  |          14|                       |  |
   :                       :  |  | ______     |-----------------------|  |
   :                       :  |  |       \  15| Field decimal count   |  |
   :                       :  |  |        \_  |=======================| _v_____
   |                       |  |  |
519|                       |  |  |
   |-----------------------|  |  |   
520| Terminator          *3|__v__v_
   |=======================|    |
521| Records               |    |
   :                       :    |
   :                       :    |
   :                       :    |
   :                       :    |
  n|                       |    |
   |__End_of_File__________| ___v____  End of file ( 1Ah )  *11
*1
dBASE II version no: 02h
*2
Sum of lengths of all fields + 1 (deletion flag). Max. length is 1,000 bytes
*3
0Dh if all 32 fields present, otherwise 00h.
*4
Field type: C, N or L
*5
Max. 32 fields

The Structure of dBASE II index file

This was previously presented as the structure of dBASE III index files. Checking with the actual header of an index made it obvious, that it did NOT fit with dBASE III index files ( In that case several of the most essential key fields should be NULL values ).

    _______________________  _______
 0 | (Reserved)            |  ^
 1 |                       |  |
   |-----------------------|  |
 2 | Node number of        |  |
 3 | root node             |  |
   |-----------------------|  |
 4 | Node number of        | Anchor
 5 | next available node   |  node
   |-----------------------| description
 6 | Length of key      *1 |  |
   |-----------------------|  |
 7 | Size of key entry  *2 |  |
   |-----------------------|  |
 8 | Maximum keys/node  *3 |  |
   |-----------------------|  |
 9 | Field type            |  |
   |-----------------------|  |
 10| Key expression in     |  |
   | ASCII                 |  |
   :                       :  |
   :                       :  |
   |                       |  |
109| (00h terminated)      |  |
   |-----------------------|  |
110| (Unused)              |  |
   |                       |  |            _
   :                       :  |           /   |=======================|
   :                       :  |          /   0| Pointer to lower level|
   |                       |  |         /    1| (next page)           |
511| ( 16 bits )           |  |        /      |-----------------------|
   |=======================| _v_____  /      2| Record number         |
  0| No.of keys in node    |  ^      /       3|                       |
   |-----------------------| _|_____/         |-----------------------|
  1| Array of key entries  |  |              4| Key expression        |
   |                       | Index            |                       |
   |                       | record           :                       :
   |-----------------------| _|_____          :                       :
   :                       :  |     \        N|                       |
511|                       |  |      \______  |=======================|
   |=======================| _v_____
*1
Key length in bytes + 2
*2
Bytes in key expression + 2
*3
00h
Character field
(else)
Numeric field


The Structure of dBASE II Memory Files (*.mem)

    _______________________  _______
 0 |                       |  ^
 1 | Variable name         |  |
   : terminated by 00h     : Header
   :                       :  |
 9 |                       |  |
10 |                       |  |
   |-----------------------|  |
11 | Variable type     *1  |  |    
   |-----------------------|  |
12 | Length of stored value|  |
   |-----------------------|  |
13 | ( Reserved )          |  |
14 |                       |  |
   |-----------------------|  |
15 | Field length  (binary)|  | *2
   |-----------------------|  |
16 | Decimal count (binary)|  |
   |-----------------------|  |
17 | ( Reserved )   00h    |  |
18 | ( Reserved )   00h    |  |
   |-----------------------|  |
19 | Value of variable     |  |
   :                    *3 :  |
   :                       :  |
   :                       :  |
   :                       :__V_____
N  |=======================|
*1
C3h
Character variable
CEh
Numerical variable
CCh
Logical variable
*2
"E" marks the start of a definition
*3
Text
entries might have leading 00h, if text is shorter than field
Logical
17 bytes are reserved, but only the last byte is used for 00h (false) or 01h (true).
End-of-File
Valid end of file (i.e. end of data) is indicated by 1Ah.



Examples

Description of test.dbf

Name of data file      : test.dbf
Version no.            : 5
Memo file present      : 131
No. of records         : 3
Length of header       : 193
Length of records      : 279
Date for latest change : 19960814
No. of fields          : 5
Current record         : 0
Crypted                : no
mdx/cdx file           : no
broken transaction     : no



Multi user information :  00 00 00 00 00 00 00 00 00 00 00 00 00


Field descriptions :
  Name          Type    length  Decimal
# ID            N       5       0
# MSG           C       254     0
# NOTE          M       10      0
# BOOLEAN       L       1       0
# DATES         D       8       0



Description of test.ndx

A index made on ID field in test.dbf

Description of test.dbt

A memo file containing the NOTE field from test.dbf


Offset  0 1 2 3  4 5 6 7  8 9 A B  C D E F

000000  83600811 03000000 C1001701 00000000  .`..............
        ^^------ !!!!!!!!
000010  00000000 00000000 00000000 00000000  ................
000020  49440000 00000000 0000004E 0700DA3F  ID.........N...?
000030  05000000 01000000 00000000 00000000  ................
000040  4D534700 00000000 00000043 0C00DA3F  MSG........C...?
000050  FE000000 01000000 00000000 00000000  ................
000060  4E4F5445 00000000 0000004D 0A01DA3F  NOTE.......M...?
000070  0A000000 01000000 00000000 00000000  ................
000080  424F4F4C 45414E00 0000004C 1401DA3F  BOOLEAN....L...?
000090  01000000 01000000 00000000 00000000  ................
0000A0  44415445 53000000 00000044 1501DA3F  DATES......D...?
0000B0  08000000 01000000 00000000 00000000  ................
0000C0  0D202020 20203152 65636F72 64206E6F  .     1Record no
0000D0  20312020 20202020 20202020 20202020   1              
0000E0  20202020 20202020 20202020 20202020                  
0000F0  20202020 20202020 20202020 20202020                  
000100  20202020 20202020 20202020 20202020                  
000110  20202020 20202020 20202020 20202020                  
000120  20202020 20202020 20202020 20202020                  
000130  20202020 20202020 20202020 20202020                  
000140  20202020 20202020 20202020 20202020                  
000150  20202020 20202020 20202020 20202020                  
000160  20202020 20202020 20202020 20202020                  
000170  20202020 20202020 20202020 20202020                  
000180  20202020 20202020 20202020 20202020                  
000190  20202020 20202020 20202020 20202020                  
0001A0  20202020 20202020 20202020 20202020                  
0001B0  20202020 20202020 20202020 20202020                  
0001C0  20202020 20202020 20202020 20203120                1 
0001D0  31393936 30383133 2A202020 20324E6F  19960813*    2No
0001E0  20322020 20202020 20202020 20202020   2              
0001F0  20202020 20202020 20202020 20202020                  
000200  20202020 20202020 20202020 20202020                  
000210  20202020 20202020 20202020 20202020                  
000220  20202020 20202020 20202020 20202020                  
000230  20202020 20202020 20202020 20202020                  
000240  20202020 20202020 20202020 20202020                  
000250  20202020 20202020 20202020 20202020                  
000260  20202020 20202020 20202020 20202020                  
000270  20202020 20202020 20202020 20202020                  
000280  20202020 20202020 20202020 20202020                  
000290  20202020 20202020 20202020 20202020                  
0002A0  20202020 20202020 20202020 20202020                  
0002B0  20202020 20202020 20202020 20202020                  
0002C0  20202020 20202020 20202020 20202020                  
0002D0  20202020 20202020 20202020 20202020                  
0002E0  20202020 20325931 39393630 38313420       2Y19960814 
0002F0  20202020 334D6573 73616765 206E6F20      3Message no 
000300  33202020 20202020 20202020 20202020  3               
000310  20202020 20202020 20202020 20202020                  
000320  20202020 20202020 20202020 20202020                  
000330  20202020 20202020 20202020 20202020                  
000340  20202020 20202020 20202020 20202020                  
000350  20202020 20202020 20202020 20202020                  
000360  20202020 20202020 20202020 20202020                  
000370  20202020 20202020 20202020 20202020                  
000380  20202020 20202020 20202020 20202020                  
000390  20202020 20202020 20202020 20202020                  
0003A0  20202020 20202020 20202020 20202020                  
0003B0  20202020 20202020 20202020 20202020                  
0003C0  20202020 20202020 20202020 20202020                  
0003D0  20202020 20202020 20202020 20202020                  
0003E0  20202020 20202020 20202020 20202020                  
0003F0  20202020 20202020 20202020 334E3139              3N19
000400  39363031 30321A                      960102.



Hex dump of test.ndx

000000  01000000 02000000 00000000 08001F00  ................
000010  01001000 00000000 49442000 80028403  ........ID .....
000020  31002B00 03000100 03000100 01000100  1.+.............
000030  01000100 01000100 01000100 01000100  ................
000040  01000100 01000100 01000100 01000100  ................
000050  01000100 01000100 01000100 01000100  ................
000060  01000100 01000100 01000100 01000100  ................
000070  01000100 01000100 01000100 01000100  ................
000080  01000100 01000100 01000100 01000100  ................
000090  01000100 01000100 01000100 01000100  ................
0000A0  01000100 01000100 01000100 01000100  ................
0000B0  01000100 01000100 01000100 01000100  ................
0000C0  01000100 01000100 01000100 01000100  ................
0000D0  01000100 01000100 01000100 01000100  ................
0000E0  01000100 01000100 01000100 01000100  ................
0000F0  01000100 01D3EA03 DABA5800 03D03BDA  ..........X...;.
000100  770CB8FE FFA20E69 5F5E8BE5 5DCB33DB  w......i_^..].3.
000110  8EC3B452 CD218CC0 0BC37410 268E47FE  ...R.!....t.&.G.
000120  26803E00 004D7504 8C060069 8E060269  &.>..Mu....i...i
000130  8CC1268B 1E010026 8B160300 83EA58BE  ..&....&......X.
000140  00008B3E 0669A100 69C70600 6900008E  ...>.i..i...i...
000150  C03BC174 153BC774 1C263B1E 01007515  .;.t.;.t.&;...u.
000160  4626A103 00050200 03D0833E 00690075  F&.........>.i.u
000170  048C0600 6926803E 00004D75 0A8CC026  ....i&.>..Mu...&
000180  03060300 40EBC889 56FE8936 0C69F746  ....@...V..6.i.F
000190  06100075 6AF74606 0100745C 1EB067B4  ...uj.F...t\..g.
0001A0  35CD218C C88ED8BE 15A5BF0A 00B90800  5.!.............
0001B0  F3A61F75 43B440CD 670AE475 3BB446CD  ...uC.@.g..u;.F.
0001C0  670AE475 33C86F7C 26D632D6 326A01A5  g..u3.o|&.2.2j..
0001D0  3420007C 26E4326C 10881411 346431F0  4 .|&.2l....4d1.
0001E0  32643104 00FA3340 07881415 34643133  2d1...3@....4d13
0001F0  003000EB 3F494400 F7460610 00754BF7  .0..?ID..F...uK.
000200  03000000 00000000 01000000 00000000  ................
000210  0000F03F 00000000 02000000 00000000  ...?............
000220  00000040 00000000 03000000 00000000  ...@............
000230  00000840 00000000 5F03C102 5F035101  ...@...._..._.Q.
000240  7B007C00 7D005101 6C036D03 57026E03  {.|.}.Q.l.m.W.n.
000250  AE025702 54025101 A7025101 FB015900  ..W.T.Q...Q...Y.
000260  31005101 0C025D03 5101C302 C402C502  1.Q...].Q.......
000270  C602C702 C802C902 CA025101 C5010802  ..........Q.....
000280  AE034201 9B000902 2F02DA00 0A02FD02  ..B...../.......
000290  06000800 09000A00 0B000C00 0D000E00  ................
0002A0  0F000700 AB00AD00 AE00AF00 B000B100  ................
0002B0  B200B300 B400AC00 C5011F03 51014201  ............Q.B.
0002C0  5101DD01 5101DA00 5101FD02 C5015101  Q...Q...Q.....Q.
0002D0  51014201 51015101 51015101 5101FD02  Q.B.Q.Q.Q.Q.Q...
0002E0  51015101 51015101 51015101 43035101  Q.Q.Q.Q.Q.Q.C.Q.
0002F0  5101FD02 D2025F03 DC025F03 E0025F03  Q....._..._..._.
000300  DB025F03 DF025F03 DD025F03 DE025F03  .._..._..._..._.
000310  5702E102 57025402 51015602 E202D302  W...W.T.Q.V.....
000320  5201D402 AE02AF02 B002B102 B202B302  R...............
000330  52015402 51015E00 5F006000 61005101  R.T.Q.^._.`.a.Q.
000340  5602D502 D3025201 D802D902 5201DA02  V.....R.....R...
000350  AF02B002 52015702 54025101 CB02CC02  ....R.W.T.Q.....
000360  CD02CE02 CF02D002 51015602 AD02AE02  ........Q.V.....
000370  AF02B002 B102B202 54025702 51015602  ........T.W.Q.V.
000380  D602D302 5201AE02 D7025402 57025101  ....R.....T.W.Q.
000390  80023100 51018002 84033100 51018002  ..1.Q.....1.Q...
0003A0  31005101 11015F03 51014800 49005101  1.Q..._.Q.H.I.Q.
0003B0  A600C102 51014C03 31005101 4C038602  ....Q.L.1.Q.L...
0003C0  31005101 56021B00 54021D00 56025201  1.Q.V...T...V.R.
0003D0  5F031C00 51025602 AE02AF02 5802B002  _...Q.V.....X...
0003E0  B1025002 52015702 54025101 50025402  ..P.R.W.T.Q.P.T.
0003F0  1E001F00 51022000 5602B102 B302B502  ....Q. .V.......


Hex dump of test.dbt

           *1       *2
        vvvvvvvv vvvvvvvv
000000  04000000 8701021D 03000002 5E126431  ............^.d1
000010  03000000 00000300 00008701 021D0300  ................   \
000020  00025E12 64310300 00000000 02000000  ..^.d1..........    |
000030  8701021D 03000002 5E126431 03000000  ........^.d1....    |
000040  00000100 00006572 69632020 44617465  ......eric  Date    |
000050  20202020 204C6F67 6963616C 20204D65       Logical  Me    |
000060  6D6F2020 20202000 FF7604E8 26CF83C4  mo     ..v..&...    |
000070  0C5E5FC9 C3908B76 048B4606 50568976  .^_....v..F.PV.v    |
000080  EA8946EC 900EE855 9B83C404 C45EEA2A  ..F....U.....^.*    |
000090  E4268A47 24C45E0A 268907C4 5EEA268A  .&.G$.^.&...^.&.    | Header
0000A0  47048E46 10268905 C45EEA26 F6471610  G..F.&...^.&.G..    | (mostly
0000B0  7503E9A3 00C45E0A 26832F02 5E5FC9C3  u.....^.&./.^_..    | garbage)
0000C0  6A01EB9A 16261F11 1F110300 C1009219  j....&..........    |
0000D0  00B8D80A BE197C26 16262411 24110300  ......|&.&$.$...    |
0000E0  D500A619 00B8E20A D2197C26 BF186DD0  ..........|&..m.    |
0000F0  0670A107 A1080672 CC026431 7C26BA19  .p.....r..d1|&..    |
000100  DC01CC19 D2196431 2F001100 21002F00  ......d1/...!./.    |
000110  6D00D21A 0318CC19 21000300 D2196431  m.......!.....d1    |
000120  11002100 1E1B6431 03002020 20006163  ..!...d1..   .ac    |
000130  74657200 5E5FC9C3 8B760023 2300268A  ter.^_...v.##.&.    |
000140  44032AE4 8CC1C45E 0A268907 8EC1268A  D.*....^.&....&.    |
000150  44028E46 10268905 5E5FC9C3 C8060000  D..F.&..^_......    |
000160  57568B4E 108B7E14 32C0F406 F10A1200  WV.N..~.2.......    |
000170  F10A4400 8E1A3C1A F6006C22 08000F00  ..D...<...l"....    |
000180  07000002 0A00246F 0A02DE13 D0367C26  ......$o.....6|&    |
000190  2E018221 06727C26 0814820A F10A0700  ...!.r|&........    |
0001A0  0A00D036 00020A00 D0360000 00020700  ...6.....6......    |
0001B0  00060000 0000D136 2C14E707 F10A0F00  .......6,.......    |
0001C0  10001900 D036726D 7C260000 07000000  .....6rm|&......    |
0001D0  00008C6D 08002A14 00007C26 9A018221  ...m..*...|&...!    |
0001E0  46727C26 4614CB00 F10A0700 00000000  Fr|&F...........    |
0001F0  00000700 0F060000 00008C6D 7C264E14  ...........m|&N.   /
000200  54686973 20697320 61206D65 6D6F2066  This is a memo f   \ <-
000210  6F726520 7265636F 7264206E 6F206F6E  ore record no on    |  | *3
000220  651A1A11 C4D92E20 4C656176 65206D65  e...... Leave me    |<-
000230  6E75202D 201B1A2E 20426C61 636B626F  nu - ... Blackbo    |
000240  61726420 2D204631 302E0052 616E6765  ard - F10..Range    |
000250  2076616C 7565206D 75737420 6265206E   value must be n    |
000260  756D6572 69632E20 20507265 73732061  umeric.  Press a    |
000270  6E79206B 65792074 6F20636F 6E74696E  ny key to contin    |
000280  75652E00 2500EA08 00AA209A D0027F1D  ue..%..... .....    |
000290  2400EA00 00911F9A D0027F1D 1100EA00  $...............    |
0002A0  00451E9A D0027F1D 0800EA14 08D21D9A  .E..............    |
0002B0  D0027F1D 1000EA00 00451E9A D0027F1D  .........E......    |
0002C0  1900EA00 00D21D9A D0027F1D 0C00EA00  ................    |
0002D0  00D21D9A D0027F1D 1800EA00 00D21D9A  ................    |
0002E0  D0027F1D 0A00EA00 00D21D9A D0027F1D  ................    |
0002F0  1300EA00 0068219A D0027F1D 1200EA00  .....h!.........    |
000300  0068219A D0027F1D 1400EA00 0068219A  .h!..........h!.    |
000310  D0027F1D 1600EA00 0068219A D0027F1D  .........h!.....    |
000320  1600EA05 0368219A D0027F1D 1500EA00  .....h!.........    |
000330  0068219A D0027F1D 1200EA24 0968219A  .h!........$.h!.    |
000340  D0027F1D 1200EAC8 0E68219A D0027F1D  .........h!.....    |
000350  1200EA82 1268219A D0027F1D 1200EABD  .....h!.........    |
000360  0168219A D0027F1D 1200EAA8 1468219A  .h!..........h!.    |
000370  D0027F1D 1200EA7D 0068219A D0027F1D  .......}.h!.....    |
000380  1200EA3D 0068219A D0027F1D 1200EAB2  ...=.h!.........    |
000390  0068219A D0027F1D 1200EA1A 0D68219A  .h!..........h!.    |
0003A0  D0027F1D 1200EAE3 1268219A D0027F1D  .........h!.....    |
0003B0  1200EA44 1368219A D0027F1D 2400EA35  ...D.h!.....$..5    |
0003C0  09911F9A D0027F1D 2400EA4F 0B911F9A  ........$..O....    |
0003D0  D0027F1D 2400EA56 1E911F9A D0027F1D  ....$..V........    |
0003E0  2400EAC7 1E911F00 00000000 00000000  $...............    |
0003F0  BE000026 8B8C0400 41742E26 8B940800  ...&....At.&....   _|
000400  54686973 20697320 6D656D6F 20666F72  This is memo for   \ <- Second
000410  20726563 6F726420 321A1A1C 00040000   record 2.......    |<- entry
000420  E54F5445 30332020 4E445800 00000000  .OTE03  NDX.....    |
000430  00000000 00002099 8C1F8945 00040000  ...... ....E....    |
000440  E54F5445 30202020 44425400 00000000  .OTE0   DBT.....    |
000450  00000000 00009C94 821F9345 00040000  ...........E....    |
000460  E54F5445 30202020 44424600 00000000  .OTE0   DBF.....    | Second 
000470  00000000 00009C94 821F9445 28020000  ...........E(...    | block
000480  E54F5445 30342020 4E445800 00000000  .OTE04  NDX.....    |
000490  00000000 00002232 8D1F6E1C 00040000  ......"2..n.....    |
0004A0  E5455820 20202020 20202000 00000000  .EX        .....    |
0004B0  00000000 00004C32 8D1F8A45 FD2F0000  ......L2...E./..    |
0004C0  E545447B 45442020 45444320 00000000  .ED{ED  EDC ....    |
0004D0  00000000 00008532 8D1F0000 00000000  .......2........    |
0004E0  E545447B 45443120 45445420 00000000  .ED{ED1 EDT ....    |
0004F0  00000000 00008532 8D1F0000 00000000  .......2........    |
000500  E545447B 45443120 45444220 00000000  .ED{ED1 EDB ....    |
000510  00000000 00008532 8D1F0000 00000000  .......2........    |
000520  E545447B 45442020 45445320 00000000  .ED{ED  EDS ....    |
000530  00000000 00008532 8D1F8D45 00100000  .......2...E....    |
000540  00000000 00000000 00000000 00000000  ................    |
000550  00000000 00000000 00000000 00000000  ................    |
000560  00000000 00000000 00000000 00000000  ................    |
000570  00000000 00000000 00000000 00000000  ................    |
000580  00000000 00000000 00000000 00000000  ................    |
000590  00000000 00000000 00000000 00000000  ................    |
0005A0  00000000 00000000 00000000 00000000  ................    |
0005B0  00000000 00000000 00000000 00000000  ................    |
0005C0  00000000 00000000 00000000 00000000  ................    |
0005D0  00000000 00000000 00000000 00000000  ................    |
0005E0  00000000 00000000 00000000 00000000  ................    |
0005F0  00000000 00000000 00000000 00000000  ................   _|
000600  54686973 20697320 6D656D6F 20331A1A  This is memo 3..   <- 3rd entry *4)
*1)
First 4 bytes indicates no. of next free block
*2)
(FoxBase) Size of blocks. This is a dBASE III+ file and byte 4-511 is just garbage.
*3)
First entry (terminated by 1Ah 1Ah)
*4)
NOTE! Last entry is NOT a complete block. dBASE does not write the full block to the memo file. The block contains the memo + terminator (1Ah 1Ah)

dBASE Specifications

dBASE II dBASE III dBASE IV
Max. no. of records 65,535 1,000,000,000 1,000,000,000
Max. fields per record 32 128 255
Max. data files open 10 10
Max. index files per open database 7 47
Max. record size in bytes 1,000 4,000 4000
Max. records per file 65,535
Max. bytes per file 8,000,000
Max. memory variables - 256
Max. memory for variables - 6,000 bytes *3
No. of data types 5 6
Max. size of MEMO file 5000 bytes 64000 bytes
Max. character field size in bytes 254 254 254
Max. numerical field size in bytes 19 20
Size of logical field 1 byte 1 byte 1 byte
Size of date field 8 bytes 8 bytes
Size of memo pointer in DBF - 10 bytes
Size of floating point - 1-2
*3 Can be expanded to 31 KB using CONFIG, 6 KB is mentioned as default.


List of File extensions

.$$$ temporary file (dBASE III)
.$db temporary file (dBASE IV)
.act FoxDoc Action Diagrams (FoxPro)
.app application object file (dBASE Application Generator)
.app generated application (FoxPro)
.bak Backup file (dBASE )
.bar horizontal bar menu object file (dBASE Application Generator)
.bin Binary files (dBASE)
.bch batch process object file (dBASE Application Generator)
.cac dBASE IV executable when caching on/off (see cachedb.bat)
.cat catalog (dBASE IV)
.cdx compound index (FoxPro)
.ch header file (Clipper 5)
.cht interface file for ChartMaster (dBASE)
.clp compiler script file (clip list) (Clipper 5)
.cmd command (dBASE - Waffle)
.cod template source file (dBASE Application Generator)
.cpt encrypted memo file (dBASE)
.crp encrypted database (dBASE IV)
.ctl control file (dBASE IV - Aldus Setup)
.cvt backup file for CONVERTed database file (dBASE IV)
.db configuration (dBASE IV - dBFast)
.db$ temporary file (dBASE)
.db2 database (dBASE II)
.db3 database (dBASE III)
.dbf database file (dBASE III/IV - FoxPro - dBFast - DataBoss)
.dbk database backup (dBASE IV)
.dbo compiled program (dBASE IV)
.dbt FoxBASE+ style memo (FoxPro)
.dbt memo file for database w/same name (dBASE IV - dBFast)
.def Definitions list (dBASE)
.dif Data Interchange Format or VisiCal file. Used with APPEND FROM and COPY (dBASE)
.doc Documentation text file (dBASE Application Generator)
.fil files list object file (dBASE Application Generator)
.fky macro file (FoxPro)
.fmo compiled format file (dBASE IV)
.fmt format file (dBASE IV - FoxPro - Clipper 5 - dBFast)
.fp configuration file (FoxPro)
.fpc catalog (FoxPro)
.fpt memo (FoxPro)
.fr3 renamed dBASE III+ form file (dBASE IV)
.frg uncompiled report file (dBASE IV)
.frm report file (dBASE IV - Clipper 5 - dBFast)
.fro compiled report file (dBASE IV)
.frt report memo (FoxPro)
.frx report (FoxPro)
.fw2 Framework spreadsheet or database file (Framework - dBASE)
.fxp compiled format (FoxPro)
.gen compiled template (dBASE Application Generator)
.idx index (many - FoxPro)
.ind include index (dBASE IV)
.inx index (Foxbase)
.key Key macro library (dBASE)
.lbg label generator data (dBASE IV)
.lbl label (dBASE IV - Clipper 5 - dBFast)
.lbo compiled label (dBASE IV)
.lbt label memo (FoxPro)
.lbx label (FoxPro)
.ld1 overlay file (dBASE)
.log Transaction log file (dBASE)
.mbk multiple index file backup (dBASE IV)
.mdx multiple index file (dBASE IV)
.mem memory variable save file (dBASE IV - FoxPro)
.mnt menu memo (FoxPro)
.mnx menu (FoxPro)
.mpr generated program (FoxPro)
.mpx compiled menu program (FoxPro)
.ndx index file (dBASE II - III - IV - dBFast)
.npi source for DGEN.EXE intepreter (dBASE Application Generator)
.ntx index file (Clipper 5)
.pjt project memo (FoxPro)
.pjx project (FoxPro)
.plb library (FoxPro)
.pll pre-linked library (Clipper 5)
.plt pre-linked transfer file (Clipper 5)
.pop pop-up menu object (dBASE Application Generator)
.ppo pre-processor output (Clipper 5)
.pr2 printer driver (dBASE IV)
.pr3 PostScript printer driver (dBASE IV)
.prf printer driver (dBASE IV)
.prg program source (dBASE IV - FoxPro - Clipper 5 - dBFast)
.prs procedure (dBASE IV)
.prt Print dump (dBASE)
.prx compiled program (FoxPro)
.qbe saved query (Query By Example) (dBASE IV - Quattro Pro)
.qbo compiled query (dBASE IV)
.qpr generated query program (FoxPro)
.qpx compiled query program (FoxPro)
.qry query (dBASE IV)
.res dBASE resources (dBASE IV)
.rpd Rapid file. Used for IMPORT/EXPORT and from APPEND, FROM and COPY (dBASE)
.sc3 renamed dBASE III screen mask file (dBASE IV)
.scr screen - screen snapshot (dBASE IV - Procomm Plus)
.sct screen memo (FoxPro)
.scx screen (FoxPro)
.spr genarated screen program (FoxPro)
.spx compiled screen program (FoxPro)
.str structure list object file (dBASE Application Generator)
.t44 Temporary file for Sort or Index (dBASE IV)
.tbk memo backup (dBASE IV - FoxPro)
.tvf table view settings (dBASE)
.upd update data (dBASE)
.upo compiled update data (dBASE)
.val values list object file (dBASE Application Generator)
.vew view file (Clipper 5, Lotus Approach)
.vue view (dBASE IV - FoxPro)
.w44 temporary file for Sort or Index (dBASE)
.wfm form object (dBASE Form Designer)
.win window file (FoxPro - dBASE)


HISTORY

1999-03-08
Minor additions.
1998-11-28
Updating some links.
1998-09-21
The path to CxBase : A Perl Library for manipulating Xbase files fixed: http://www.e-bachmann.dk/archive/cxbase.zip
1998-08-26
More references.
1998-08-24
More references (Perl).
List of File extentions.
1998-07-16
FoxPro/FoxBase specific notes.
1998-04-07
More references. Java and Rexx.
1998-03-26
New references.
1998-03-03
A reference to a Perl Xbase manipulation library added.
1997-09-29
A reference to a Perl Xbase manipulation library added.
1997-09-17
Fixing minor bug in reference list
Reference list: Pratap Pereira moved to new host
1997-08-11
Updating structure of:
data file (*.dbf): codepages etc.
Memo files (*.dbt): dBASE III & dBASE IV does *not* use the same structure
Memory files (*.mem): Full structure of file
Clipper Index (*.NTX): Page structure added. Header structure improved
dBASE II data and index file
Adding structure of:
Fox Pro object and memo files (*.fpt)

dBASEII Memory files (*.mem)
dBASE IV Multple index files (*.MDX)
1997-06-02
Fixing bug in calculating dates for "The Year 2000": 1900 + 255 = 2155
1997-04-16
Note on Year 2000 problems.

Correcting page description in index file .ndx.

1997-04-18
Added the chapter:

The Structure of Compound Index files (*.cdx) by David Kuechler
1997-03-10
Still more references and updates of references.

Refining description of NTX file.

1997-01-27
Description of .MEM (Memory index file) and .NTX (Clipper Index File).

Description of Database Container in Visual FoxPro

More references and various minor changes in text.

1997-01-09
Description of .MDX (Multiple index file) - This seems to be a mistake :-(
1996-11-27
Document converted to HTML
1996-11-19
Minor fixes:

Elements in Field Descriptor Array are exact 32 B long.

Typing error in data type Float.

"What to check on opening a .DBF file" added.

1996-10-18
Chapter on read/write locks using share by Phil Barnett (philb@iag.net)
1996-10-15
Change in description of structure of index files.

Major mistake! The previous version described the structure for dBASE II index files.
Only excuse: This mistake was made by several of my sources :-(

1996-10-03
First public version of this document (as far as I remember :-)

REFERENCE LIST

These references describe, where I found the documents - not where they are now. If you find dead links - please keep me informed.
  1. Bachmann, Erik:
  2. Xbase : File format description / Erik Bachmann. - Roskilde, Denmark : Clickety Click Software, 1996-1998. - aprox. 38 pg. ; ASCII text file / HTML document

    URL: http://www.e-bachmann.dk/docs/xbase.html or

    URL: http://www.e-bachmann.dk/docs/xbase.txt (ASCII Text)

     

  3. Born, Günter:
  4. The File Formats Handbook / Günter Born. - London : Thomson, 1995. - 1274 pg. - ISBN 1-85032-117-5

     

  5. CA-Clipper File Structures : Detailed Structure Information. . - ( Xbase Techniques. ; Computer Associates International, Inc. ). - 1993. - Pg. 7-10
  6. Reference from: Ben Engbers

     

  7. Castro, L.:
  8. Advanced programmer's guide featuring dBASE III and dBASE II / L. Castro. - Culver City, California, USA : Ashton-Tate, 1985. - 10+664 pg. - ISBN 0-912677-05-8

    Note: Literature list and Terminology list

     

  9. dBASE .DBF File Structure. - (Borland Technical Documents ; TI12821)
  10. URL: http://loki.borland.com/winbin/bds.exe?getdoc+2821+Delphi

     

  11. Dechert, Alan
  12. Fixing dBASE DOS applications for Year 2000 Compliance

    URL: http://members.aol.com/adechert/y2kscan.htm

     

  13. Eacker, Brad:
  14. DBF : A set of tools and library routines to manipulate xbase files / Brad Eacker : Silicon Graphics, 1994. - Computer files ; C source ; ASCII text

    Note: UUNET vol. 43 1994

    Abstract: UUnet : volume43 (Period: 08 Jun 94 - 24 Jul 94), dbf/part0[1-2] : dbf - xbase manipulation package

    URL: ftp://ftp.uu.net/usenet/comp.sources.misc/volumen43/dbf/part01.Z

    URL: ftp://ftp.uu.net/usenet/comp.sources.misc/volumen43/dbf/part02.Z

     

  15. Err : "Not a Database File". - (Microsoft Knowledge Base. ; Article Q98743)
  16. URL: http://support.microsoft.com/support/kb/articles/q98/7/43.asp

     

  17. General Format of .dbf files in Xbase Language. - (Multisoft GmbH ; 1996)
  18. URL: http://www.fship.com/pub/multisoft/flagship/docu/dbfspecs.txt

     

  19. Gmelch, Rasca:
  20. libdbf : simple routines for accessing xbase data files / Rasca Gmelch. - Berlin, 1996. - Computer files ; C source ; ASCII text

    URL: URL: http://www.komm.hdk-berlin.de/~rasca/dbflib/

     

  21. Hogan, T.:
  22. The Programmers's PC sourcebook : Reference tables for IBM PCs and compatibles, PS/2 systems, EISA-based systems, MS-DOS operating system through version 5, Microsoft Windows through version 3 : Hundred of new charts and tables / T. Hogan. - Redmond, Washington, USA : Microsoft Press, 1991. - Multiple pagination. - ISBN 1-55615-321-X

     

  23. Kunkel, Gary
  24. Xbase DBMS / Gary Kunkel

    This product provides C and C++ programmers a class and function library for manipulating Xbase type datafiles and indices.
    XBase DBMS currently includes routines to support multi-user access for .DBF databases, fields, Dbase IV memo fields (variable length fields), dates, record and file locking and indexes (.NDX). There is also an HTML user interface class which works well with the Apache Web Server. Future releases will support filters, enhanced .MDX index files, transaction support, Dbase III memo fields, a client server configuration, secure data options and other enhancements requesteed by anyone using this library.

    URL: http://www.startech.keller.tx.us/xbase/xbase.html

     

  25. How to Modify the Table Header from FoxPro. - (Microsoft Knowledge Base. ; Article Q139758 ; )
  26. URL: http://support.microsoft.com/support/kb/articles/q139/7/58.asp

     

  27. OOxBase (Version 2.10) - A SOM Interface To dBase (OS/2) (BETA). - (American Coders, LTD.)
  28. URL: http://www.americancoders.com/

     

  29. Pazdziora, Jan
  30. DBD::XBase : Module for dealing with XBase files
    Package DBD::XBase contains module XBase that can read and write dbf and dbt file, and also alpha release of DBI driver, that will be further extended to support everything required by DBI 0.92.

    URL: http://www.fi.muni.cz/~adelton/perl/

    Author Address: adelton@fi.muni.cz

     

  31. Pereira, Pratap
  32. Xbase.pm v. 1.07 : a module for perl 5

    Author Source: http://www.best.com/~pereira

    Author Address: pereira@best.com

    This module seems to be unsupported. Try: Jan Pazdziora's "Module for dealing with XBase files".

     

  33. RexxBase (Version 2.21) - The dBase Database For REXX. - (American Coders, LTD.)
  34. URL: http://www.americancoders.com/RexxBase.html

     

  35. Seay, Doug:
  36. CxBase : A Perl Library for manipulating Xbase files / Doug Seay

    Author Source: CxBase.zip

    Author Address: seay@absyss.fr
    It seems to be unsupported :-)

    This package was former known as CodeBase, but the name was changed (by me) to CxBase due to a violation on Sequiters copyright on the name CodeBase.

     

  37. Simpson, Alan:
  38. dBASE III PLUS : Programmer's Reference Guide / Alan Simpson. - Almeda : Sybex Inc., 1987. - 1029 pg. - ISBN 0-89588-301-5

    Abstract: Data file structure and memo file structure for xBase

     

  39. Spence, Rick:
  40. Clipper Programming Guide / Rick Spence. - 2.nd edition. - Microtrend Books, Slawson Communications, Inc. - ISBN 0-915391-41-4

     

  41. Stevens, A.:
  42. Turbo C : Memory-resistent utilities, screen I/O and programming techniques / A. Stevens. - Portland, Origon, USA : MIS Press, 1987. - 10+315 pg. - ISBN 0-943518-35-0

    Note: Video Windows and TSR utility programs

     

  43. Townsend, Carl:
  44. Mastering dBASE III : A Structured Approach / Carl Townsend. - Berkeley : Sybex Inc., 1985. - ISBN 0-89588-301-5

    Abstract: Data file structure and index file structure for xBase

     

  45. Walden, J.:
  46. File formats for popular PC software : A programmer's reference / J. Walden. - New York, New York, USA : Wiley, 1986. - 16+287 pg. - ISBN 0-471-83671-0

     

  47. WANG, Thomas:
  48. Transactional Locking, Part 1 / Thomas Wang (wang@cup.hp.com)

    URL: http://www.concentric.net/~Ttwang/tech/locks1.htm

     

  49. What FoxPro Checks When Opening a .DBF File. - (Microsoft Knowledge Base. ; Article Q119763)
  50. URL: http://support.microsoft.com/support/kb/articles/q119/7/63.asp

     

  51. WHITE, Gary:
  52. Some dBASE Stuff / Gary White

    This is my dBASE stuff. It ranges from old stuff for the DOS versions of dBASE to new stuff for Visual dBASE version 7. There's even some stuff that's non-version-specific. You'll also find links to some other very good sites. Don't forget the FAQ (Frequently Asked Questions), which is included in a site search.

    URL: http://www.apptools.com/dbase/index.html

     

  53. White Paper on CodeBase 6, xBASE technology, and Sequiter's OLE DB development plan. - (Sequiter Software)
  54. URL: http://www.sequiter.com/papers/wpcbase6.htm

     

  55. xBaseJ - Java Objects To Read and Write to dBase Files. - (American Coders, LTD.)
  56. URL: http://www.americancoders.com/xBaseJ.html


END OF FILE