Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dbase 3 File type 1

Status
Not open for further replies.

ryupb

MIS
Aug 31, 2004
25
US
Hi,

is there a way that I can convert or copy a vfp6.0 dbf into a dbase 3 .dbf format??

the "copy to filename type fox2x" works but is this a .dbf dbase 3 format???
 
ryupb,

Not sure what the distinct differences were between the dbase 3 format and the Fox 2x format of the dbf file.

If this is a one-time deal and doing it manually will work you could export your table to excel and then export a DBase 3 table from there...however there are some limitations that you may run into with excel's ability to export the data you have properly (depending on what it is) so this might not even work for you.

boyd.gif

 
Ryupb,

You can use COPY TO ... TYPE FOXPLUS. The actual DBF file will be in dBASE III format (which is identical to the old Foxbase Plus). But the indexes won't be. You would have to either forgo the indexes in the dBASE version, or use dBASE itself to re-index.

Also, this technique won't work if the VFP table has memo fields. If necessary, exclude the memos from the COPY process.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks Mike and Craig...

Craig - unfortunately this will be an ongoing process and not a one time deal only....


Mike - Good thing, the file that will be copied into another format doesnt have any indexing or memo fields involve..

will try your suggestion and get back to you...
 
I tried researching this a bit, I wanted to know what the structural differences were between all the different dbf versions and couldn't find a single place on the web that carried this information. Anyone know somewhere that has this information available?

boyd.gif

 
Try faq184-3162
This program contains all headerinfo that is also listed on a microsoft webpage...

Rob.
 
Craig,

The dBASE file format (as opposed to the VFP variation on it) was published many years ago, but I can't find a copy of it to hand.

Some time in the 20th Century, I wrote a Turbo Pascal program that browsed and searched dBASE files. I must have had some information about the file structure then, but I don't now.

As far as I remember, it's only the file header that is different in VFP, and probably only a byte or two.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks for the replies. Mike, that's what I'm wondering, is whether it is just the flag in the header denoting the version that changed or if anything else changed from one dbase version to the next all the way to today's VFP 9 dbf's. Also, any changes that were made to the index files and the way they are constructed. But alas, there is information about the actual structure available (as rob has pointed out) but nothing where a comparison or changes by version can be readily looked at. There are differences I'm quite sure other than just that flag, but perhaps the differences have mainly to do with the fpt and cdx and idx files and not with the actual dbf?

boyd.gif

 
You're sure that there are differences other than just that flag.
Please point out WHAT it is you're sure of?

I'm sure that there are NO differences other than that flag as far as dbase III / Clipper / Force and Foxpro 2.x databases are concerned.
Since VFP the structures have changed (longer) and new types of variables were made possible.

I regularly use dbf files on all these "platforms" and I can tell you that all information can be exchanged without a problem after changing the significant byte.

In the Clipper environment libraries are available to create .ndx, .ntx, .idx and .cdx index although the .idx and .cdx are not 100% compatible with those created by foxpro unless you have the codebase libraries to create them.

If you are interested I can show you codebase sourcecode to create all those indexes.
Those sources are in C++/C

Rob.
 
Thank you for your last post rob444, star for you. And if you have the time, I would love to see those sources. There is an email link on my site that you can use. I'd post it here but I'm not sure if Tek-Tips obfuscates email links or not and I am trying to minimize spam these days. [smile]

boyd.gif

 
OK Craig.
Thanks for the star.
If I have the time to seek for those sources I'll send them to you.

For the record the 'old' structure info of the dbf files.

Rob.


----------------------------------------------------------------------------
Genaral Format of .dbf files in Xbase languages 18-Nov-96
----------------------------------------------------------------------------
Applies for / supported by:

FS = FlagShip D3 = dBaseIII+
Fb = FoxBase D4 = dBaseIV
Fp = FoxPro D5 = dBaseV
CL = Clipper


1. DBF Structure
================

Byte Description
------+--------------------------------------
0..n .dbf header (see 2 for size, byte 8)
n+1 1st record of fixed length (see 2&3) \
2nd record (see 2 for size, byte 10) \ if dbf is
... / not empty
last record /
last optional: 0x1a (eof byte)


2. DBF Header (variable size, depending on field count)
=======================================================

Byte Size Contents Description Applies for (supported by)
----+----+--------+----------------------------+-----------------------------
00 1 0x03 plain .dbf FS, D3, D4, D5, Fb, Fp, CL
0x04 plain .dbf D4, D5 (FS)
0x05 plain .dbf D5, Fp (FS)
0x43 with .dbv memo var size FS
0xB3 with .dbv and .dbt memo FS
0x83 with .dbt memo FS, D3, D4, D5, Fb, Fp, CL
0x8B with .dbt memo in D4 format D4, D5
0x8E with SQL table D4, D5
0xF5 with .fmp memo Fp
01 3 YYMMDD Last update digits all
04 4 ulong Number of records in file all
08 2 ushort Header size in bytes all
10 2 ushort Record size in bytes all
12 2 0,0 Reserved all
14 1 0x01 Begin transaction D4, D5
0x00 End Transaction D4, D5
0x00 ignored FS, D3, Fb, Fp, CL
15 1 0x01 Encryptpted D4, D5
0x00 normal visible all
16 12 0 (1) multi-user environment use D4,D5
28 1 0x01 production index exists Fp, D4, D5
0x00 index upon demand all
29 1 n language driver ID D4, D5
0x01 codepage 437 DOS USA Fp
0x02 codepage 850 DOS Multi ling Fp
0x03 codepage 1251 Windows ANSI Fp
0xC8 codepage 1250 Windows EE Fp
0x00 ignored FS, D3, Fb, Fp, CL
30 2 0,0 reserved all
32 n*32 Field Descriptor, see (2a) all
+1 1 0x0D Header Record Terminator all


2a. Field descriptor array in dbf header (fix 32 bytes for each field)
========================================

Byte Size Contents Description Applies for (supported by)
----+----+--------+----------------------------+-----------------------------
0 11 ASCI field name, 0x00 termin. all
11 1 ASCI field type (see 2b) all
12 4 n,n,n,n fld address in memory D3
n,n,0,0 offset from record begin Fp
0,0,0,0 ignored FS, D4, D5, Fb, CL
16 1 byte Field length, bin (see 2b) all \ FS,CL: for C field type,
17 1 byte decimal count, bin all / both used for fld lng
18 2 0,0 reserved all
20 1 byte Work area ID D4, D5
0x00 unused FS, D3, Fb, Fp, CL
21 2 n,n multi-user dBase D3, D4, D5
0,0 ignored FS, Fb, Fp, CL
23 1 0x01 Set Fields D3, D4, D5
0x00 ignored FS, Fb, Fp, CL
24 7 0..0 reserved all
31 1 0x01 Field is in .mdx index D4, D5
0x00 ignored FS, D3, Fb, Fp, CL


2b. Field type and size in dbf header, field descriptor (1 byte)
=======================================================

Size Type Description/Storage Applies for (supported by)
------+---------+------------------------------+-----------------------------
C 1..n Char ASCII (OEM code page chars) all
rest= space, not \0 term.
n = 1..64kb (using deci count) FS
n = 1..32kb (using deci count) Fp, CL
n = 1..254 all
D 8 Date 8 Ascii digits (0..9) in the all
YYYYMMDD format
F 1..n Numeric Ascii digits (-.0123456789) FS, D4, D5, Fp
variable pos. of float.point
n = 1..20
N 1..n Numeric Ascii digits (-.0123456789) all
fix posit/no float.point
n = 1..20 FS, Fp, CL
n = 1..18 D3, D4, D5, Fb
L 1 Logical Ascii chars (YyNnTtFf space) FS, D3, Fb, Fp, CL
Ascii chars (YyNnTtFf ?) D4, D5 (FS)
M 10 Memo 10 digits repres. the start all
block posit. in .dbt file, or
10spaces if no entry in memo
V 10 Variable Variable, bin/asc data in .dbv FS
4bytes bin= start pos in memo
4bytes bin= block size
1byte = subtype
1byte = reserved (0x1a)
10spaces if no entry in .dbv
P 10 Picture binary data in .ftp Fp
structure like M
B 10 Binary binary data in .dbt D5
structure like M
G 10 General OLE objects D5, Fp
structure like M
2 2 short int binary int max +/- 32767 FS
4 4 long int binary int max +/- 2147483647 FS
8 8 double binary signed double IEEE FS


3. Each Dbf record (fix length)
==================

Byte Size Description Applies for (supported by)
------+----+--------------------------------------+--------------------------
0 1 deleted flag "*" or not deleted " " all
1..n 1.. x-times contents of fields, fixed all
length, unterminated.
For n, see (2) byte 10..11

DBF FILE STRUCTURE
~~~~~~~~~~~~~~~~~~

BYTES DESCRIPTION
00 FoxBase+, FoxPro, dBaseIII+, dBaseIV, no memo - 0x03
FoxBase+, dBaseIII+ with memo - 0x83
FoxPro with memo - 0xF5
dBaseIV with memo - 0x8B
dBaseIV with SQL Table - 0x8E

01-03 Last update, format YYYYMMDD **correction: it is YYMMDD**
04-07 Number of records in file (32-bit number)
08-09 Number of bytes in header (16-bit number)
10-11 Number of bytes in record (16-bit number)
12-13 Reserved, fill with 0x00
14 dBaseIV flag, incomplete transaction
Begin Transaction sets it to 0x01
End Transaction or RollBack reset it to 0x00

15 Encryption flag, encrypted 0x01 else 0x00
Changing the flag does not encrypt or decrypt the records

16-27 dBaseIV multi-user environment use
28 Production index exists - 0x01 else 0x00
29 dBaseIV language driver ID
30-31 Reserved fill with 0x00
32-n Field Descriptor array
n+1 Header Record Terminator - 0x0D

FIELD DESCRIPTOR ARRAY TABLE
BYTES DESCRIPTION
0-10 Field Name ASCII padded with 0x00
11 Field Type Identifier (see table)
12-15 Displacement of field in record
16 Field length in bytes
17 Field decimal places
18-19 Reserved
20 dBaseIV work area ID
21-30 Reserved
31 Field is part of production index - 0x01 else 0x00

FIELD IDENTIFIER TABLE
ASCII DESCRIPTION
C Character
D Date, format YYYYMMDD
F Floating Point
G General - FoxPro addition
L Logical, T:t,F:f,Y:y,N:n,?-not initialized
M Memo (stored as 10 digits representing the dbt block number)
N Numeric
P Picture - FoxPro addition

Note all dbf field records begin with a deleted flag field.
If record is deleted - 0x2A (asterisk) else 0x20 (space)
End of file is marked with 0x1A


----------------------------------------------------------------------------
Genaral Format of .dbf files in Xbase languages 18-Nov-96
----------------------------------------------------------------------------
Applies for / supported by:

FS = FlagShip D3 = dBaseIII+
Fb = FoxBase D4 = dBaseIV
Fp = FoxPro D5 = dBaseV
CL = Clipper


1. DBF Structure
================

Byte Description
------+--------------------------------------
0..n .dbf header (see 2 for size, byte 8)
n+1 1st record of fixed length (see 2&3) \
2nd record (see 2 for size, byte 10) \ if dbf is
... / not empty
last record /
last optional: 0x1a (eof byte)


2. DBF Header (variable size, depending on field count)
=======================================================

Byte Size Contents Description Applies for (supported by)
----+----+--------+----------------------------+-----------------------------
00 1 0x03 plain .dbf FS, D3, D4, D5, Fb, Fp, CL
0x04 plain .dbf D4, D5 (FS)
0x05 plain .dbf D5, Fp (FS)
0x43 with .dbv memo var size FS
0xB3 with .dbv and .dbt memo FS
0x83 with .dbt memo FS, D3, D4, D5, Fb, Fp, CL
0x8B with .dbt memo in D4 format D4, D5
0x8E with SQL table D4, D5
0xF5 with .fmp memo Fp
01 3 YYMMDD Last update digits all
04 4 ulong Number of records in file all
08 2 ushort Header size in bytes all
10 2 ushort Record size in bytes all
12 2 0,0 Reserved all
14 1 0x01 Begin transaction D4, D5
0x00 End Transaction D4, D5
0x00 ignored FS, D3, Fb, Fp, CL
15 1 0x01 Encryptpted D4, D5
0x00 normal visible all
16 12 0 (1) multi-user environment use D4,D5
28 1 0x01 production index exists Fp, D4, D5
0x00 index upon demand all
29 1 n language driver ID D4, D5
0x01 codepage 437 DOS USA Fp
0x02 codepage 850 DOS Multi ling Fp
0x03 codepage 1251 Windows ANSI Fp
0xC8 codepage 1250 Windows EE Fp
0x00 ignored FS, D3, Fb, Fp, CL
30 2 0,0 reserved all
32 n*32 Field Descriptor, see (2a) all
+1 1 0x0D Header Record Terminator all


2a. Field descriptor array in dbf header (fix 32 bytes for each field)
========================================

Byte Size Contents Description Applies for (supported by)
----+----+--------+----------------------------+-----------------------------
0 11 ASCI field name, 0x00 termin. all
11 1 ASCI field type (see 2b) all
12 4 n,n,n,n fld address in memory D3
n,n,0,0 offset from record begin Fp
0,0,0,0 ignored FS, D4, D5, Fb, CL
16 1 byte Field length, bin (see 2b) all \ FS,CL: for C field type,
17 1 byte decimal count, bin all / both used for fld lng
18 2 0,0 reserved all
20 1 byte Work area ID D4, D5
0x00 unused FS, D3, Fb, Fp, CL
21 2 n,n multi-user dBase D3, D4, D5
0,0 ignored FS, Fb, Fp, CL
23 1 0x01 Set Fields D3, D4, D5
0x00 ignored FS, Fb, Fp, CL
24 7 0..0 reserved all
31 1 0x01 Field is in .mdx index D4, D5
0x00 ignored FS, D3, Fb, Fp, CL


2b. Field type and size in dbf header, field descriptor (1 byte)
=======================================================

Size Type Description/Storage Applies for (supported by)
------+---------+------------------------------+-----------------------------
C 1..n Char ASCII (OEM code page chars) all
rest= space, not \0 term.
n = 1..64kb (using deci count) FS
n = 1..32kb (using deci count) Fp, CL
n = 1..254 all
D 8 Date 8 Ascii digits (0..9) in the all
YYYYMMDD format
F 1..n Numeric Ascii digits (-.0123456789) FS, D4, D5, Fp
variable pos. of float.point
n = 1..20
N 1..n Numeric Ascii digits (-.0123456789) all
fix posit/no float.point
n = 1..20 FS, Fp, CL
n = 1..18 D3, D4, D5, Fb
L 1 Logical Ascii chars (YyNnTtFf space) FS, D3, Fb, Fp, CL
Ascii chars (YyNnTtFf ?) D4, D5 (FS)
M 10 Memo 10 digits repres. the start all
block posit. in .dbt file, or
10spaces if no entry in memo
V 10 Variable Variable, bin/asc data in .dbv FS
4bytes bin= start pos in memo
4bytes bin= block size
1byte = subtype
1byte = reserved (0x1a)
10spaces if no entry in .dbv
P 10 Picture binary data in .ftp Fp
structure like M
B 10 Binary binary data in .dbt D5
structure like M
G 10 General OLE objects D5, Fp
structure like M
2 2 short int binary int max +/- 32767 FS
4 4 long int binary int max +/- 2147483647 FS
8 8 double binary signed double IEEE FS


3. Each Dbf record (fix length)
==================

Byte Size Description Applies for (supported by)
------+----+--------------------------------------+--------------------------
0 1 deleted flag "*" or not deleted " " all
1..n 1.. x-times contents of fields, fixed all
length, unterminated.
For n, see (2) byte 10..11


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top