[comp.databases] Header of a DBASE file

dmartel@ireq.hydro.qc.ca (Denis Martel ETUDIANT SEPT 91) (06/11/91)

  I have made a database program in C with BTRIEVE, but I
need to translate BTR files into DBASE files.  If there
somebody know the structure of the header of a DBASE file ?  

Please E-mail.

Thanks.


///////////////////////////////////

Internet : dmartel@ireq.hydro.qc.ca

///////////////////////////////////

jmt@mullauna.cs.mu.OZ.AU (James Mark THOMAS) (06/12/91)

dmartel@ireq.hydro.qc.ca (Denis Martel ETUDIANT SEPT 91) writes:
>  I have made a database program in C with BTRIEVE, but I
>need to translate BTR files into DBASE files.  If there
>somebody know the structure of the header of a DBASE file ?  
>Please E-mail.

I am also interested, so if someone has this info, could they post it on line please?

Thanks, Jim.

beacker@mips.com (Bradley Eacker) (06/13/91)

      I am including the layout file that I ftp'd from chyde.uwasa.fi
earlier this year.  I am not sure how the person involved collected
the data, though I have seen this same kind of data in the book
"PC File Formats" or something to that effect.
      If anyone has been doing any kind of work to do a PD/shareware
version of the dbase interpreter, I would be interested in trying
to compare notes.
      Just for the record, the opinions expressed here are
mine and should not reflect on anyone but me.
         Brad Eacker (beacker@mips.com)


Database file structure

The structure of a dBASE III database file is composed of a header
and data records.  The layout is given below.


dBASE III DATABASE FILE HEADER:

+---------+-------------------+---------------------------------+
|  BYTE   |     CONTENTS      |          MEANING                |
+---------+-------------------+---------------------------------+
|  0      |  1 byte           | dBASE III version number        |
|         |                   |  (03H without a .DBT file)      |
|         |                   |  (83H with a .DBT file)         |
+---------+-------------------+---------------------------------+
|  1-3    |  3 bytes          | date of last update             |
|         |                   |  (YY MM DD) in binary format    |
+---------+-------------------+---------------------------------+
|  4-7    |  32 bit number    | number of records in data file  |
+---------+-------------------+---------------------------------+
|  8-9    |  16 bit number    | length of header structure      |
+---------+-------------------+---------------------------------+
|  10-11  |  16 bit number    | length of the record            |
+---------+-------------------+---------------------------------+
|  12-31  |  20 bytes         | reserved bytes (version 1.00)   |
+---------+-------------------+---------------------------------+
|  32-n   |  32 bytes each    | field descriptor array          |
|         |                   |  (see below)                    | --+
+---------+-------------------+---------------------------------+   |
|  n+1    |  1 byte           | 0DH as the field terminator     |   |
+---------+-------------------+---------------------------------+   |
                                                                    |
                                                                    |
A FIELD DESCRIPTOR:      <------------------------------------------+

+---------+-------------------+---------------------------------+
|  BYTE   |     CONTENTS      |          MEANING                |
+---------+-------------------+---------------------------------+
|  0-10   |  11 bytes         | field name in ASCII zero-filled |
+---------+-------------------+---------------------------------+
|  11     |  1 byte           | field type in ASCII             |
|         |                   |  (C N L D or M)                 |
+---------+-------------------+---------------------------------+
|  12-15  |  32 bit number    | field data address              |
|         |                   |  (address is set in memory)     |
+---------+-------------------+---------------------------------+
|  16     |  1 byte           | field length in binary          |
+---------+-------------------+---------------------------------+
|  17     |  1 byte           | field decimal count in binary   |
+---------+-------------------+---------------------------------+
|  18-31  |  14 bytes         | reserved bytes (version 1.00)   |
+---------+-------------------+---------------------------------+


The data records are layed out as follows:

     1. Data records are preceeded by one byte that is a space (20H) if the
        record is not deleted and an asterisk (2AH) if it is deleted.

     2. Data fields are packed into records with  no  field separators or
        record terminators.

     3. Data types are stored in ASCII format as follows:

     DATA TYPE      DATA RECORD STORAGE
     ---------      --------------------------------------------
     Character      (ASCII characters)
     Numeric        - . 0 1 2 3 4 5 6 7 8 9
     Logical        ? Y y N n T t F f  (? when not initialized)
     Memo           (10 digits representing a .DBT block number)
     Date           (8 digits in YYYYMMDD format, such as
                    19840704 for July 4, 1984)

landers@vulcan.mgmt.purdue.edu (Chris Landers) (06/13/91)

The layout of a .dbf file is documented in Appendex D of Using dBase III+
Corrections noted below to the post are from page D-1


In article <4612@spim.mips.COM> beacker@mips.com (Bradley Eacker) writes:
>
>Database file structure
>
>The structure of a dBASE III database file is composed of a header
>and data records.  The layout is given below.
>
>
>dBASE III DATABASE FILE HEADER:
>
>+---------+-------------------+---------------------------------+
>|  BYTE   |     CONTENTS      |          MEANING                |
>+---------+-------------------+---------------------------------+
>|  0      |  1 byte           | dBASE III version number        |
>|         |                   |  (03H without a .DBT file)      |
>|         |                   |  (83H with a .DBT file)         |
>+---------+-------------------+---------------------------------+
>|  1-3    |  3 bytes          | date of last update             |
>|         |                   |  (YY MM DD) in binary format    |
>+---------+-------------------+---------------------------------+
				yy mm dd in bianary format?
				the book only says:  date of last update
						     (yy mm dd)

>|  4-7    |  32 bit number    | number of records in data file  |
>+---------+-------------------+---------------------------------+
>|  8-9    |  16 bit number    | length of header structure      |
>+---------+-------------------+---------------------------------+
>|  10-11  |  16 bit number    | length of the record            |
>+---------+-------------------+---------------------------------+
				 number of bytes in the record			

>|  12-31  |  20 bytes         | reserved bytes (version 1.00)   |
    12-14      3 bytes           reserved bytes
    15-27     13 bytes           reserved for multi-user
    28-31     20 bytes           reserved bytes

humm, my correction doesn't add up, but that's the book says, 
exactly as above.

>+---------+-------------------+---------------------------------+
>|  32-n   |  32 bytes each    | field descriptor array          |
>|         |                   |  (see below)                    | --+
>+---------+-------------------+---------------------------------+   |
>|  n+1    |  1 byte           | 0DH as the field terminator     |   |
>+---------+-------------------+---------------------------------+   |
>                                                                    |
>                                                                    |
>A FIELD DESCRIPTOR:      <------------------------------------------+
>
>+---------+-------------------+---------------------------------+
>|  BYTE   |     CONTENTS      |          MEANING                |
>+---------+-------------------+---------------------------------+
>|  0-10   |  11 bytes         | field name in ASCII zero-filled |
>+---------+-------------------+---------------------------------+
>|  11     |  1 byte           | field type in ASCII             |
>|         |                   |  (C N L D or M)                 |
>+---------+-------------------+---------------------------------+
>|  12-15  |  32 bit number    | field data address              |
>|         |                   |  (address is set in memory)     |
				  (not useful on disk)
this third line added to the first two.

>+---------+-------------------+---------------------------------+
>|  16     |  1 byte           | field length in binary          |
>+---------+-------------------+---------------------------------+
>|  17     |  1 byte           | field decimal count in binary   |
>+---------+-------------------+---------------------------------+
>|  18-31  |  14 bytes         | reserved bytes (version 1.00)   |
>+---------+-------------------+---------------------------------+
    18-19      2 bytes           reserved for multi-user
    20         1 byte            work area ID
    21-22      2 bytes           reserved for multi-user
    23         1 byte            SET FIELDS flag
    24-31      8 bytes           reserved bytes


>
>
>The data records are layed out as follows:
>
>     1. Data records are preceeded by one byte that is a space (20H) if the
>        record is not deleted and an asterisk (2AH) if it is deleted.
>
>     2. Data fields are packed into records with  no  field separators or
>        record terminators.
>
>     3. Data types are stored in ASCII format as follows:
>
>     DATA TYPE      DATA RECORD STORAGE
>     ---------      --------------------------------------------
>     Character      (ASCII characters)
>     Numeric        - . 0 1 2 3 4 5 6 7 8 9
>     Logical        ? Y y N n T t F f  (? when not initialized)
>     Memo           (10 digits representing a .DBT block number)
>     Date           (8 digits in YYYYMMDD format, such as
>                    19840704 for July 4, 1984)

      4. The end-of-file marker is ans ASCII 26 (1AH) character.

Structure of a database memo (.dbt) file is discussed on pages D-3 & D-4


I don't recall seeing this information in the Clipper Summer '87 manual, but
it could be in one of the readme files.

I don't know if it's found in the dBase IV manual because 
FLAME ON
I don't own dBase IV, I don't plan to buy dBase IV, and I don't use dBase IV.
I think this subject has been beat to death here!
FLAME OFF

Hope my corrections are helpful.



-- 
   <================================><===============================>
   || Christopher Landers           || PURDUE UNIVERSITY - KRAN 708 ||
   || Krannert Computing Center     || West Lafayette, IN  47907    ||
   <=================== landers@zeus.mgmt.purdue.edu ================>

tomr@dbase.a-t.com (Tom Rombouts) (06/18/91)

In article <1991Jun12.224335.7552@vulcan.mgmt.purdue.edu> landers@vulcan.mgmt.purdue.edu (Chris Landers) writes:

  [description of .DBF file format w/corrections deleted]

>I don't know if it's found in the dBase IV manual because 
>FLAME ON
>I don't own dBase IV, I don't plan to buy dBase IV, and I don't use dBase IV.
>I think this subject has been beat to death here!
>FLAME OFF

Yes, it is in the dBASE IV manual, appendix E in the 1.1 Language
Reference Manual.  (Note that some features, such as "F" data type
fields, are new with dBASE IV.)  If you really want to get into it,
there are at least four third-party C libraries available with source to 
create or manipulate .DBF files with various degrees of .DBT, .NDX, 
.MDX and .NTX support, depending on the specific library.


Tom Rombouts  Torrance 'Tater  tomr@ashtate.A-T.com