PDA

View Full Version : Playing with dbf files, headers and c++


AIyer
12-25-02, 12:13
Hi everyone!

I was wondering, does anyone know of any web-sites where they, in some detail, discuss the opening and editing of a dbf file, preferably in c++, but any other language is fine? I am trying to open and read a dbf file (oddly enough) and am having no end of difficulty in even understanding the file format.

ie, there are three structures, the table file header (ok, the main header of the file, little difficulty there), the Table Field Descriptor (I take it this is the section where columns are described), the field descriptor array (sorry? What is this used for??) and the database records (I take it, the actual data of the file!). And ideas if this breakdown is correct?

Finally, when I check my version number, using c++, and this snippet of code

<snip>
ifstream inFile("pat.dbf", ios::in|ios::binary);
unsigned char dBV = 0;
unsigned long id2 = 0;
inFile.read(&dBV,1); // byte 0

id2 = (dBV);
cout << "Raw value: " << (id2) << endl;

the result is, on running:
Raw Value: 48

Which seems to imply that the version is 0! However, some freeware dbase editors CAN open the file - so which version are they using? Do versions really matter?

Cheers
Andrew

PS I ma assuming the the version is zero as bits 0 - 2 are the version bits, and they are zero in the number 48...

playernovis
12-25-02, 12:52
have you seen this?

http://www.dbase2000.com/Knowledgebase/int/db7_file_fmt.htm

and this ?

http://community.borland.com/article/0,1410,15838,00.html

jiri

AIyer
12-26-02, 20:15
Yeah, it is the docs I have - however, it does not explain the odd numbered version I am getting!

Thanks tho.

lg48
01-08-03, 20:06
It's not only version numbers. It also indicates which driver is used to create the DBF. Different drivers, like FlexFile, Comix, Foxpro,etc., uses different kind of memo file formats and therefor use thier own descriptor as the first byte. That should prevent for instance dBase to try to open and alter memo fields in a DBF created with FlexFile or Foxpro as dBase don't understand the format of the those Memo files.

/LG

Originally posted by AIyer
Yeah, it is the docs I have - however, it does not explain the odd numbered version I am getting!

Thanks tho.