xBase File format Questions

(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?
LVL 22
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 cymbolic@aol.com if you need more info, or any .dbf utilities.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodAuthor Commented:
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.  
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.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

nietodAuthor Commented:
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 nietod@theshop.net, I would appreciate it.   (Or tell me how to find it, I don't use AOL and have no idea what FILEPILE is.)
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.  

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.
nietodAuthor Commented:
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.)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.