Solved

xBase File format Questions

Posted on 1998-05-19
7
552 Views
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?
0
Comment
Question by:nietod
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
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
END TYPE

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
END TYPE

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.
0
 
LVL 22

Author Comment

by:nietod
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.  
0
 
LVL 9

Expert Comment

by:cymbolic
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.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 22

Author Comment

by:nietod
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 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.)
0
 
LVL 9

Expert Comment

by:cymbolic
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:
C=Character
D=Date
L=Logical
M=Memo
N=Numeric
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.  


0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1025425
You can get dbflook at:
http://filepile.com/nc/start

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
Clipper
DBASE
Foxpro
etc..

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.
0
 
LVL 22

Author Comment

by:nietod
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.)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now