home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / ddf / ddf.txt next >
Text File  |  1994-02-05  |  9KB  |  217 lines

  1. Btrieve Users:
  2.  
  3.   DOWNLOAD FILE DDF.ZIP FROM Lib 15
  4.  
  5.   All you need to know about DDF files
  6.   ------------------------------------
  7.  
  8.   All DDF files are Btrieve files. VB3's new data access methods and
  9.   control and MS ACCESS need only two files, namely, FILE.DDF and FIELD.DDF.
  10.  
  11.   First three records of FILE.DDF are used to identify three files, i.e.,
  12.   FILE.DDF, FIELD.DDF and INDEX.DDF (not use by VB3 or ACCESS).
  13.  
  14.   First seventeen records of FIELD.DDF are to identify seventeen fields.
  15.   5 fields of FILE.DDF, 8 fields of FIELD.DDF and 4 fields of INDEX.DDF.
  16.  
  17.   YOU DO NOT NEED INDEX.DDF FILE TO USE BTRIEVE TABLES WITH VB3 OR ACCESS.
  18.  
  19.   A. FILE.DDF, Record Length : 97
  20.      ----------------------------
  21.  
  22.   File Name: X$File (as it appears in the first record of FILE.DDF)
  23.  
  24.   Fld Field Name   Type    Size
  25.     1 Xf$ID        Integer    2 <-File ID Starting from 1 (Unique)
  26.     2 Xf$Name      String    20 <-FileName
  27.     3 Xf$Location  String    64 <-File Location
  28.     4 Xf$Flags     Integer    1 <- =16 for 1st 3 files, =0 for your files
  29.     5 Xf$Reserved  String    10 <-Reserved
  30.  
  31.  
  32.   Key Type   Field     Size  Order
  33.     0 Unique 1 Xf$ID      2  Ascending
  34.     1 Unique 2 Xf$Name   20  Ascending
  35.  
  36.   NOTES:
  37.  
  38.    1. Field values of the first three records of FILE.DDF are:
  39.  
  40.    Xf$ID   Xf$Name    Xf$Loacation    Xf$Flags    Xf$Reserved
  41.    -----   --------   ------------    --------    -----------
  42.      1     X$File     file.ddf           16       BLANK
  43.      2     X$Field    field.ddf          16       BLANK
  44.      3     X$Index    index.ddf          16       BLANK
  45.  
  46.    For your Btrieve Tables (files), start assigning Xf$ID from 4.
  47.  
  48.    2. Xf$Name field is the value you assign to Data1.RecordSource property
  49.       or use it in an SQL statement, e.g. 'baseball teams', 'Titles'. It is
  50.       a descriptive name (NOT A DOS FILE NAME). Make sure to use a unique
  51.       name for each entry you make for your Btrieve Table in FILE.DDF
  52.       (starting from 4). VB3 uses these names to show you a DROP DOWN list
  53.       when you click on the 'three dots' of the .RecordSource property of a
  54.       Data Control.
  55.  
  56.    3. Xf$Location is the complete drive id + path + file name of your
  57.       btrieve file. Since Xf$Name is UNIQUE, VB3 can automatically use
  58.       this field to locate the Btrieve Table (file) you are trying to
  59.       access using Data Control or VB3 Data Access functions.
  60.  
  61.   B. FIELD.DDF, Length : 32
  62.      ----------------------
  63.  
  64.   File Name: X$Field (as it appears in the second entry of FILE.DDF)
  65.  
  66.  Fld Field Name  Type    Size
  67.    1 Xe$Id       Integer    2 <- Field ID starting from 1 (Unique)
  68.    2 Xe$File     Integer    2 <- File ID (Xf$ID in FILE.DDF)
  69.    3 Xe$Name     String    20 <- Field Name (May have duplicates)
  70.    4 Xe$DataType Integer    1 <- Field Type (0-13). See below
  71.    5 Xe$Offset   Integer    2 <- Field Offset starting from 0
  72.    6 Xe$Size     Integer    2 <- Field Size
  73.    7 Xe$Dec      Integer    1 <- Field decimal places (for Decimal type)
  74.    8 Xe$Flags    Integer    2 <- Reserved
  75.  
  76.  Key Type       Field     Size Orde
  77.    0 Unique     1 Xe$Id      2 Ascending
  78.  
  79.    1 Non-unique 2 Xe$File    2 Ascending
  80.  
  81.    2 Non-unique 3 Xe$Name   20 Ascending
  82.  
  83.    3 Unique     2 Xe$File    2 Ascending
  84.                 3 Xe$Name   20 Ascending
  85.  
  86.  NOTES:
  87.  
  88.    1. Field values of the first 17 records of FIELD.DDF are:
  89.  
  90.   Xe$Id Xe$File Xe$Name      Xe$DataType   Xe$Offset Xe$Size Xe$Dec Xe$Flags
  91.   ----- ------- -----------  -----------   --------- ------- ------ --------
  92.   1     1       Xf$Id        1             0          2      0      0
  93.   2     1       Xf$Name      0             2         20      0      0
  94.   3     1       Xf$Loc       0            22         64      0      0
  95.   4     1       Xf$Flags     1            86          1      0      0
  96.   5     2       Xe$Id        1             0          2      0      0
  97.   6     2       Xe$File      1             2          2      0      0
  98.   7     2       Xe$Name      0             4         20      0      0
  99.   8     2       Xe$DataType  1            24          1      0      0
  100.   9     2       Xe$Offset    1            25          2      0      0
  101.  10     2       Xe$Size      1            27          2      0      0
  102.  11     2       Xe$Dec       1            29          1      0      0
  103.  12     2       Xe$Flags     1            30          2      0      0
  104.  13     3       Xi$File      1             0          2      0      0
  105.  14     3       Xi$Field     1             2          2      0      0
  106.  15     3       Xi$Number    1             4          2      0      0
  107.  16     3       Xi$Part      1             6          2      0      0
  108.  17     3       Xi$Flags     1             8          2      0      0
  109.  
  110.   2. The Field name Xe$File is same as the Xf$ID field in FILE.DDF. This
  111.      is used by VB3 automatically to locate the field names in your
  112.      Btrieve file and fill the DROP DOWN list for the .DataField property
  113.      of a bound control.
  114.  
  115.   3. The data type of a field stored in Xe$DataType is one of the following
  116.      integer values.
  117.  
  118.      Data Type          Value           Data Type               Value
  119.      ---------          -----           ---------               -----
  120.    * string             0               logical                 7
  121.    * integer            1               numeric                 8
  122.    * float              3               bfloat                  9
  123.      date               4               lstring                 10
  124.      time               4               zstring                 11
  125.      decimal            5               note                    12
  126.      money              6               lvar                    13
  127.  
  128.    * These are the only ones I found useful in a BASIC program.
  129.      float  => SINGLE or DOUBLE
  130.      date and time data types are stored as long integers by Btrieve.
  131.  
  132.      Formulas for conversion are:
  133.  
  134.      BtrTime& = HH& * 16777216 + MM& * 65536 + SS& * 256
  135.      BtrDate& = YY& * 65536 + MM& * 256 + DD&
  136.      DateBtr$ = Format$(MM&, "00") + "/" + Format$(DD&, "00") _
  137.                 + "/" + Format$(YY&, "0000")
  138.  
  139.      TimeBtr$ = Format$(HH&, "00") + ":" + Format$(MM&, "00") _
  140.                 + ":" + Format$(SS&, "00")
  141.  
  142.      Long variables are used to avoid overflow.
  143.  
  144. ***************************************************************************
  145.  
  146.   Two ways of creating your DDF files are:
  147.  
  148.   1. VISDATA.MAK project from VB3 (or Data Manager program in VB3's 'Windows'
  149.      menu.
  150.   2. Use MS Access to create the DDF files using the FILE.DDF, FIELD.DDF,
  151.      FILE.DAT and FILED.DAT files included in the ZIP file.
  152.  
  153.   Method 1.
  154.   ---------
  155.  
  156.   Copy following files to a subdirectory. All must be in the same subdirectory.
  157.  
  158.   1. FILE.DDF
  159.   2. FIELD.DDF
  160.   3. FILE.DAT
  161.   4. FIELD.DAT
  162.  
  163.   FILE.DDF has five records. 1st three, as you know by now, are for the
  164.   dictionary files (FILE.DDF, FIELD.DDF and INDEX.DDF).
  165.  
  166.   Record 4 is for FILE.DAT. FILE.DAT is a minimal FILE.DDF i.e.
  167.   with only three records (for the three dictionary files).
  168.  
  169.   Record 5 is for FIELD.DAT. FIELD.DAT is minimal FIELD.DDF i.e.
  170.   with only 17 records (for the three dictionary files).
  171.  
  172.   Copy all these files into same subdirectory, e.g., C:\VB3.
  173.  
  174.   Now comes the bootstrap process, i.e., use DDF files and VB3/ACCESS to
  175.   create the DDF files for your Btrieve Tables.
  176.  
  177.   Use VISDATA.MAK project or 'Data Manager' from the VB3's 'Windows' menu.
  178.   Connect to Btrieve Data Base. Select FILE.DDF from VB3 subdir. You will see
  179.   two tables:
  180.  
  181.   (i) 'Files_DDF' and
  182.   (ii) 'Fields_DDF'.
  183.  
  184.   Select Data Control Option and OPEN Files_DDF Table. Start adding your
  185.   own Btrieve Files Names and Location. Assign Xf$ID starting from 4.
  186.  
  187.   Once you are done with all your Btrieve Files, OPEN 'Fields_DDF' Table and
  188.   start adding the Fields of your Btrieve files that you just entered. You
  189.   might want to open two windows and add files in 'Files_DDF' Table and fields
  190.   in 'Fields_DDF' Tables at the same time. For 'Files_DDF' table start Xe$ID
  191.   from 18.
  192.  
  193.   When you are done rename FILE.DDF and FIELD.DDF to something else and keep
  194.   them for future use. Rename FILE.DAT to FILE.DDF and FIELD.DAT to FIELD.DDF
  195.   and you are on your way to use VB3's data access methods and control with
  196.   Btrieve. And remember you can always add new files (tables) and delete the
  197.   one you don't need using the same process (re-renaming will be required)
  198.   described above.
  199.  
  200.   Method 2.
  201.   ---------
  202.  
  203.   Start MS Access 1.0/1.1/2.0. Open a 'New' database. Call it MAKEDDF.MDB.
  204.   From file menu select 'Attach Tables'. Select Btrieve. Locate 'FILE.DDF'
  205.   that is included in this ZIP file. Attach both File_DDF and Field_DDF tables.
  206.   Click OK when done. Open File_DDF and start entering info about your
  207.   Btrieve Tables. When done open Filed_DDF and start entering info about the
  208.   fields in your Btrieve Tables.
  209.  
  210.   When you are done rename FILE.DDF and FIELD.DDF to something else and keep
  211.   them for future use. Rename FILE.DAT to FILE.DDF and FIELD.DAT to FIELD.DDF
  212.   and you are on your way to use your Btrieve tables with MS Access or VB3.
  213.   Remember you can always add new files (tables) and delete the one you don't
  214.   need using the same process (re-renaming will be required) described above.
  215.  
  216. Sunil.
  217.