home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
vb_code1
/
ddf_docs
/
ddf1.txt
< prev
next >
Wrap
Text File
|
1993-10-29
|
12KB
|
265 lines
Message 1: As it appeared during VB3 beta:
Btrieve Users:
All you need to know about DDF files
------------------------------------
You will need this information to write a BASIC program to create
the DDF files. Writing such a program is not very difficult since
all the information you need to create the records for FILE.DDF
and FIELD.DDF is already in the USER DEFINED TYPES you use in your
existing BASIC programs. 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.
A. FILE.DDF, Record Length : 97
----------------------------
File Name: X$File (as it appears in the first entry 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│ <- Bit 4=1 for Dict files, 0 for User
│ 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. 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
In the BASIC or ACCESS program you write to create the DDF files for
all your Btrieve Tables (files), start assigning Xf$ID from 4.
2. Xf$Name field is the value you assign to Data1.RecordSource property.
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 the 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 the
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┬─ Order ─┐
│ 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. 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 one 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.
***************************************************************************
Message 2: As it appeared during VB3 beta:
Here is a quick way to create DDF files w/o spending a single penny.
Download the file DDF.ZIP from LIB 1. This file contains following
files:
1. FILE.DDF
2. FIELD.DDF
3. FILES.DAT
4. FIELDS.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 FILES.DAT. FILES.DAT is a minimal FILE.DDF i.e.
with only three records (for the three dictionary files).
Record 5 is for FIELDS.DAT. FIELDS.DAT is minimal FIELD.DDF i.e.
with only 17 records (for the three dictionary files).
Copy all these files into your VB3 subdirectory.
Now comes the bootstrap process i.e. use DDF files and VB3 to create your
DDF files.
Use VISDATA.MAK project. Connect to Btrieve Data Base. Select FILE.DDF
from VB3 subdir. You will see two tables (i) 'My Files' and (ii) 'My Fields'.
Select Data Control Option and OPEN My Files 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 'My Fields' 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 'My Files' Table and fields
in 'My Fields' Tables at the same time. For 'My Files' table start Xe$ID
from 18.
Note: There are some bugs in the VISDATA.MAK. Ignore 'Record x of y'
display inside the Data Control. It is not always right.
Do not worry if you make mistakes. You can always delete a record
and reenter with the same Xf$ID (or Xe$ID).
When you are done rename FILE.DDF and FIELD.DDF to something else and
FILES.DAT to FILE.DDF and FIELDS.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 described above. I wish VB3 allowed
a file name other than FILE.DDF in the .DataBaseName property. Even though
manual says so VB3 ignores the file name you enter after the last "\" in
this property and always opens file FILE.DDF. If this was true then renaming
won't be necessary and adding and deleting tables will become a matter just
of using VISDATA.MAK.
It might seem to like a tedious task to enter all these fields but the
rewards you will reap when you are done are astounding. VB3 Data Access
is deceptively simple yet enormously powerful.
***************************************************************************
Message 3: As it appeared during VB3 beta:
Three ways of creating your DDF files are:
1. VISDATA.MAK project from VB3
2. write your own program with Data Controls in VB3
3. Use MS Access to create the DDF files using the FILE.DDF, FIELD.DDF,
FILE.DAT and FILED.DAT files included in the DDF1.ZIP.
**** WARNING **** WARNING ****
YOU MUST COPY ALL FILES TO 'C:\VB3' SUBDIR BEFORE YOU CAN USE ANY ONE OF
THE ABOVE THREE METHODS OF CREATING DDF FILES.
I have included DB1.MDB database that is attached to Btrieve Tables
File_DDF (i.e. FILE.DAT) and Field_DDF (i.e. FIELD.DAT) that can be
used with MS Access. MS Access tables are easier to use than
VISDATA.MAK program for data entry.
As explained in my previous messages FILE.DDF and FIELD.DDF contain
information about FILE.dat and FIELD.dat. You use one of the three
methods listed above to populate FILE.dat and FIELD.dat further with
the information about your Btrieve files and when done rename/copy
them to FILE.DDF and FIELD.DDF that can be used with VB3 or MS Access
to access your Btrieve files.
Use DB1.MDB with ACCESS or use FILE.DDF with VISDATA.MAK.
As stated before, MS Access is easier to use then VISDATA.MAK because
it allows you to enter data in a grid like control (DataSheet).
Don't you wish GRID control was Data aware with direct data entry into
cells ? But I know why we don't get everything we ask for in VB.
Eventually we will, but by that time VB will VB 7.0 (like PDS). All VB
users would have upgraded VB 7 times. And then VB 7.0 will get
replaced by something called 'Invisible Basic' and all of us here will
start Beta testing this new 'Invisible Basic' asking for new features
that we won't get and the whole cycle will start again. You and I will
get old (out dated) and our kids (poor souls) will get in this viscous
cycle of 'asking, not getting, getting eventually and then starting all
over again'. What a life !
Sunil.
P.S. Data aware Grid controls are now available from Sheridan Software and
FarPoint. Both are VERY good.
I have uploaded DDF1.ZIP file in this forum and asked the Sysop to
make it public.
I have also developed a VB module that uses WBTRCALL.DLL from Novell
to access Btrieve files from VB/VBA. This approach does not require
DDF files. Its is also somewhat faster than VB3's data access methods
and controls. But as usual you need to declare user type for every
Btrieve file you use. if you use VB3's data access you don't need any
user types to access the fields in your Btrieve files. In fact it is
not straight forward to copy record pointed by BookMark property to
an user defined type record variable. If you need it let me know.
I wish VB3 allowed something similar to
Lset MyTypeVar = Data1.RecordSet.BookMark
to copy the entire record. May be VB4 will.