home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
vb_code1
/
ddf
/
ddf.txt
next >
Wrap
Text File
|
1994-02-05
|
9KB
|
217 lines
Btrieve Users:
DOWNLOAD FILE DDF.ZIP FROM Lib 15
All you need to know about DDF files
------------------------------------
All DDF files are Btrieve files. VB3's new data access methods and
control and MS ACCESS need only two files, namely, FILE.DDF and FIELD.DDF.
First three records of FILE.DDF are used to identify three files, i.e.,
FILE.DDF, FIELD.DDF and INDEX.DDF (not use by VB3 or ACCESS).
First seventeen records of FIELD.DDF are to identify seventeen fields.
5 fields of FILE.DDF, 8 fields of FIELD.DDF and 4 fields of INDEX.DDF.
YOU DO NOT NEED INDEX.DDF FILE TO USE BTRIEVE TABLES WITH VB3 OR ACCESS.
A. FILE.DDF, Record Length : 97
----------------------------
File Name: X$File (as it appears in the first record of FILE.DDF)
Fld Field Name Type Size
1 Xf$ID Integer 2 <-File ID Starting from 1 (Unique)
2 Xf$Name String 20 <-FileName
3 Xf$Location String 64 <-File Location
4 Xf$Flags Integer 1 <- =16 for 1st 3 files, =0 for your files
5 Xf$Reserved String 10 <-Reserved
Key Type Field Size Order
0 Unique 1 Xf$ID 2 Ascending
1 Unique 2 Xf$Name 20 Ascending
NOTES:
1. Field values of the first three records of FILE.DDF are:
Xf$ID Xf$Name Xf$Loacation Xf$Flags Xf$Reserved
----- -------- ------------ -------- -----------
1 X$File file.ddf 16 BLANK
2 X$Field field.ddf 16 BLANK
3 X$Index index.ddf 16 BLANK
For your Btrieve Tables (files), start assigning Xf$ID from 4.
2. Xf$Name field is the value you assign to Data1.RecordSource property
or use it in an SQL statement, e.g. 'baseball teams', 'Titles'. It is
a descriptive name (NOT A DOS FILE NAME). Make sure to use a unique
name for each entry you make for your Btrieve Table in FILE.DDF
(starting from 4). VB3 uses these names to show you a DROP DOWN list
when you click on the 'three dots' of the .RecordSource property of a
Data Control.
3. Xf$Location is the complete drive id + path + file name of your
btrieve file. Since Xf$Name is UNIQUE, VB3 can automatically use
this field to locate the Btrieve Table (file) you are trying to
access using Data Control or VB3 Data Access functions.
B. FIELD.DDF, Length : 32
----------------------
File Name: X$Field (as it appears in the second entry of FILE.DDF)
Fld Field Name Type Size
1 Xe$Id Integer 2 <- Field ID starting from 1 (Unique)
2 Xe$File Integer 2 <- File ID (Xf$ID in FILE.DDF)
3 Xe$Name String 20 <- Field Name (May have duplicates)
4 Xe$DataType Integer 1 <- Field Type (0-13). See below
5 Xe$Offset Integer 2 <- Field Offset starting from 0
6 Xe$Size Integer 2 <- Field Size
7 Xe$Dec Integer 1 <- Field decimal places (for Decimal type)
8 Xe$Flags Integer 2 <- Reserved
Key Type Field Size Orde
0 Unique 1 Xe$Id 2 Ascending
1 Non-unique 2 Xe$File 2 Ascending
2 Non-unique 3 Xe$Name 20 Ascending
3 Unique 2 Xe$File 2 Ascending
3 Xe$Name 20 Ascending
NOTES:
1. Field values of the first 17 records of FIELD.DDF are:
Xe$Id Xe$File Xe$Name Xe$DataType Xe$Offset Xe$Size Xe$Dec Xe$Flags
----- ------- ----------- ----------- --------- ------- ------ --------
1 1 Xf$Id 1 0 2 0 0
2 1 Xf$Name 0 2 20 0 0
3 1 Xf$Loc 0 22 64 0 0
4 1 Xf$Flags 1 86 1 0 0
5 2 Xe$Id 1 0 2 0 0
6 2 Xe$File 1 2 2 0 0
7 2 Xe$Name 0 4 20 0 0
8 2 Xe$DataType 1 24 1 0 0
9 2 Xe$Offset 1 25 2 0 0
10 2 Xe$Size 1 27 2 0 0
11 2 Xe$Dec 1 29 1 0 0
12 2 Xe$Flags 1 30 2 0 0
13 3 Xi$File 1 0 2 0 0
14 3 Xi$Field 1 2 2 0 0
15 3 Xi$Number 1 4 2 0 0
16 3 Xi$Part 1 6 2 0 0
17 3 Xi$Flags 1 8 2 0 0
2. The Field name Xe$File is same as the Xf$ID field in FILE.DDF. This
is used by VB3 automatically to locate the field names in your
Btrieve file and fill the DROP DOWN list for the .DataField property
of a bound control.
3. The data type of a field stored in Xe$DataType is one of the following
integer values.
Data Type Value Data Type Value
--------- ----- --------- -----
* string 0 logical 7
* integer 1 numeric 8
* float 3 bfloat 9
date 4 lstring 10
time 4 zstring 11
decimal 5 note 12
money 6 lvar 13
* These are the only ones I found useful in a BASIC program.
float => SINGLE or DOUBLE
date and time data types are stored as long integers by Btrieve.
Formulas for conversion are:
BtrTime& = HH& * 16777216 + MM& * 65536 + SS& * 256
BtrDate& = YY& * 65536 + MM& * 256 + DD&
DateBtr$ = Format$(MM&, "00") + "/" + Format$(DD&, "00") _
+ "/" + Format$(YY&, "0000")
TimeBtr$ = Format$(HH&, "00") + ":" + Format$(MM&, "00") _
+ ":" + Format$(SS&, "00")
Long variables are used to avoid overflow.
***************************************************************************
Two ways of creating your DDF files are:
1. VISDATA.MAK project from VB3 (or Data Manager program in VB3's 'Windows'
menu.
2. Use MS Access to create the DDF files using the FILE.DDF, FIELD.DDF,
FILE.DAT and FILED.DAT files included in the ZIP file.
Method 1.
---------
Copy following files to a subdirectory. All must be in the same subdirectory.
1. FILE.DDF
2. FIELD.DDF
3. FILE.DAT
4. FIELD.DAT
FILE.DDF has five records. 1st three, as you know by now, are for the
dictionary files (FILE.DDF, FIELD.DDF and INDEX.DDF).
Record 4 is for FILE.DAT. FILE.DAT is a minimal FILE.DDF i.e.
with only three records (for the three dictionary files).
Record 5 is for FIELD.DAT. FIELD.DAT is minimal FIELD.DDF i.e.
with only 17 records (for the three dictionary files).
Copy all these files into same subdirectory, e.g., C:\VB3.
Now comes the bootstrap process, i.e., use DDF files and VB3/ACCESS to
create the DDF files for your Btrieve Tables.
Use VISDATA.MAK project or 'Data Manager' from the VB3's 'Windows' menu.
Connect to Btrieve Data Base. Select FILE.DDF from VB3 subdir. You will see
two tables:
(i) 'Files_DDF' and
(ii) 'Fields_DDF'.
Select Data Control Option and OPEN Files_DDF Table. Start adding your
own Btrieve Files Names and Location. Assign Xf$ID starting from 4.
Once you are done with all your Btrieve Files, OPEN 'Fields_DDF' Table and
start adding the Fields of your Btrieve files that you just entered. You
might want to open two windows and add files in 'Files_DDF' Table and fields
in 'Fields_DDF' Tables at the same time. For 'Files_DDF' table start Xe$ID
from 18.
When you are done rename FILE.DDF and FIELD.DDF to something else and keep
them for future use. Rename FILE.DAT to FILE.DDF and FIELD.DAT to FIELD.DDF
and you are on your way to use VB3's data access methods and control with
Btrieve. And remember you can always add new files (tables) and delete the
one you don't need using the same process (re-renaming will be required)
described above.
Method 2.
---------
Start MS Access 1.0/1.1/2.0. Open a 'New' database. Call it MAKEDDF.MDB.
From file menu select 'Attach Tables'. Select Btrieve. Locate 'FILE.DDF'
that is included in this ZIP file. Attach both File_DDF and Field_DDF tables.
Click OK when done. Open File_DDF and start entering info about your
Btrieve Tables. When done open Filed_DDF and start entering info about the
fields in your Btrieve Tables.
When you are done rename FILE.DDF and FIELD.DDF to something else and keep
them for future use. Rename FILE.DAT to FILE.DDF and FIELD.DAT to FIELD.DDF
and you are on your way to use your Btrieve tables with MS Access or VB3.
Remember you can always add new files (tables) and delete the one you don't
need using the same process (re-renaming will be required) described above.
Sunil.