xBase File format Questions

Posted on 1998-05-19
Last Modified: 2010-05-18
(1) Where can I find a complete reference (preferably free on the internet, but a readibly available book will do) for the xBase III file formats.  I would like it to include any differences in the formats produced by different products, like access, clipper, etc.  

(2) Is it possible to imbed some additional information in the file xBase file header for my progam's use?  Can I, for example, indicate it has a larger header size than normal and embed som information after the array of field information?
Question by:nietod
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Accepted Solution

cymbolic earned 50 total points
ID: 1025420
Following is a type structure showing the format of headers and fields in a .DBF.  If you are working withthese files I recommend you download DBFLOOK.  You can find it on AOL or on FILEPILE on the internet.  There is available unused space in each field record in the dbf header.  You can stick stuff in there if you dare.  I have never seen it used for anything by any .dbf development system.

The structure of these .dbf files can be found in the appendix of some of the original development systems manuals, or in some third party technical books on CLipper, Dbase, FoxPro, etc.

See below:

structure of the beginning of each .dbf:
TYPE dbfhead
      dbver AS STRING * 1  'Version
      uyr  AS STRING * 1
      umon  AS STRING * 1
      uday   AS STRING * 1
      nrecs AS LONG
      hlen AS INTEGER
      recl AS INTEGER
      x AS STRING * 20

Followed by repeating format field records:
TYPE dbfdetl
      fname AS STRING * 11
      ftype AS STRING * 1
      coff AS INTEGER
      clen AS INTEGER
      flen AS STRING * 1
      fdec AS STRING * 1
      maxl AS INTEGER
      xxx AS STRING * 12

Then, you can get the number of fields like this:

If hdrec is derined as your header type:
      OPEN file$ FOR BINARY AS #1
      GET #1, , hdrec
      nflds = (hdrec.hlen - 33) \ 32

At the end of the header, a signature string follows:
sign$ = CHR$(13) + CHR$(0)

then each record follows, with position one of each record being the delete byte.  If it is an "*", then the record is deleted.

email me at if you need more info, or any .dbf utilities.
LVL 22

Author Comment

ID: 1025421
I need a much more precise file format.  That is less precise than what I already have.  (I need to know what informaiton to place in each field.  What values to place in the initial type byte, the date fields, etc.)  

Placing additional data after each field is insufficient.  There is not enough space if the number of fields is too small.  Also some xBase formats do use this area.  

Expert Comment

ID: 1025422
You can examine the header information easily using a hex editor, and determine the different dbver settings that originate from different development systems.  I use Verne Buerg's List program, and display in hex mode.

Native date fields are text based in the format YYYYMMDD, but many apps have bypassed the native format and store dates as text strings.  Outside of the space at the end of the header, and some space within each field descriptor in the header, you have no other places to store data in the header of a .dbf.

Also, in the structures I gave you , the coff, clen, and maxl defined areas in the field descriptors are also available.  I use that area internally to track information on each field when I read in a dbf header.  I have a whole series of utilities to work with .dbf files, and .dbt and .fpt files without using any database development language.  It's all done in my own code.  

Perhaps if you ask more specific questions, I can answer them.

It would be nice to include the index file names in the .dbf header, then a .dbf would be self referencing.  I also have information on the .ndx .ntx .cdx .mdx index header formats as well, and can tell you internally how the index pages are constructed.

you really should get DBFLOOK.  It allows you to examine the records directly, and color codes by field type, so you can see exactly how each field is formatted by type., as well as get a complete readout on the header information in a dbf, plus many other capabilities as well. I am the author.
Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

LVL 22

Author Comment

ID: 1025423
I still need MUCH more precise information.  I know the size of the and position of the information in the header already.  I need to know how it is used.  For example (and this is not an exhaustive list, this is to give you an idea of what I am looking for.)

How is the field name terminated?  Space or zero or both?  Does the terminator have to pad the name the whole way to the end or is one terminator enough?  Is case important in a field name?  What characters are allowed in a field name? What are the field type letters?  If a field does not use decimals, like a character field, does the decinmals have to be set to zero or other specific value.  Are there maximum values for the lengths and decimals?  

That is why I need some sort of reference that spells out the file format.  I already have two files that are several pages long that list some of that sort of information.  However it is not enough as one program (clipper's DBU) can read my files fine and one (MS Access) cannot.  There are plenty of other xBase programs out there and I need my files to be compatible with all of them.  

I would appreciate it if you sent me your utility.  It would be interesting to see if it can handle my files.  Does it report errors if it detects that a file is corrupted?  It you would send it to, I would appreciate it.   (Or tell me how to find it, I don't use AOL and have no idea what FILEPILE is.)

Expert Comment

ID: 1025424
field names are terminated with a hex 0.  One hex 0 terminator character is enough.  Field names should be upper case.

Field type letters are:
If a field is not a Numeric type, the dec character is ignored.
If a field is numeric type, then if the Dec character is > 0 the field has an implied decimal point.  Fields can not be longer that 255 characters.  Maximum record length varies by development system. Numbers can not exceed length of internal floating point numbers on the operating hardware, because they are automatically converted from strings to numerics internally when read in if they are typed as numerics in the database.

We have used records exceding 8k in length under Clipper and longer records are possible, but sometimes you incur internal memory prolems/limitations on various development systems with large size records and very large amounts of fields.  The program has to store both the header and realetd information, and copies of the record currently being worked on.  Many of these internal development limitations are not published, and involve common shared memory useage as well.  


Expert Comment

ID: 1025425
You can get dbflook at:

Set your area to MS DOS, and search for DBFLOOK.  Take the most recent copy.

Now what you really need is a matrix of differrent development systems and their limitations regarding dbf handling.  It would look something like this:
                    Max Fields  Max Rlen  Max Nrecs  Index Type  etc.  
MS Access

I haven't seen a collected set of this info, but if you do manage to accumulate it, I sure would like to see what you come up with.
LVL 22

Author Comment

ID: 1025426
Your utility seems to read the file fine.  which does not help!  I'm goign to give you an A for your help, but I may ask the question again in the next few days in hopes of finding a more complete reference.   So don't answer that one (unless you find such a reference.)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question