home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / ddf_docs / ddf1.txt < prev    next >
Text File  |  1993-10-29  |  12KB  |  265 lines

  1. Message 1: As it appeared during VB3 beta:
  2.  
  3. Btrieve Users:
  4.   All you need to know about DDF files
  5.   ------------------------------------
  6.  
  7.   You will need this information to write a BASIC program to  create
  8.   the DDF files. Writing such a program is not very difficult  since
  9.   all the information you need to create  the  records for FILE.DDF
  10.   and FIELD.DDF is already in the USER DEFINED TYPES you use in  your
  11.   existing BASIC programs. All DDF files are Btrieve files. VB3's new
  12.   data access methods and control and MS ACCESS need only two files,
  13.   namely, FILE.DDF and FIELD.DDF.
  14.  
  15.   A. FILE.DDF, Record Length : 97
  16.      ----------------------------
  17.  
  18.   File Name: X$File (as it appears in the first entry of FILE.DDF)
  19.  
  20.   ┌Fld┬─ Field Name ──┬─Type──┬Size┐
  21.   │  1│Xf$ID          │Integer│   2│ <- File ID Starting from 1 (Unique)
  22.   │  2│Xf$Name        │String │  20│ <- FileName
  23.   │  3│Xf$Location    │String │  64│ <- File Location
  24.   │  4│Xf$Flags       │Integer│   1│ <- Bit 4=1 for Dict files, 0 for User
  25.   │  5│Xf$Reserved    │String │  10│ <- Reserved
  26.   └───┴───────────────┴───────┴────┘
  27.  
  28.   ┌Key┬─ Type ─┬─ Field ──┬Size┬─ Order ──┐
  29.   │  0│Unique  │1 Xf$ID   │2   │Ascending │
  30.   ├───┼────────┼──────────┼────┼──────────┤
  31.   │  1│Unique  │2 Xf$Name │20  │Ascending │
  32.   └───┴────────┴──────────┴────┴──────────┘
  33.  
  34.   NOTES:
  35.  
  36.    1. First three records of FILE.DDF are:
  37.  
  38.    Xf$ID   Xf$Name    Xf$Loacation    Xf$Flags    Xf$Reserved
  39.    -----   --------   ------------    --------    -----------
  40.      1     X$File     file.ddf           16       BLANK
  41.      2     X$Field    field.ddf          16       BLANK
  42.      3     X$Index    index.ddf          16       BLANK
  43.  
  44.      In the BASIC or ACCESS program you write to create the DDF files for
  45.      all your Btrieve Tables (files), start assigning Xf$ID from 4.
  46.  
  47.    2. Xf$Name field is the value you assign to Data1.RecordSource property.
  48.       e.g. 'baseball teams', 'Titles'. It is a descriptive name (NOT A
  49.       DOS FILE NAME). Make sure to use a unique name for each entry you
  50.       make for your Btrieve Table in FILE.DDF (starting from 4). VB3
  51.       uses these names to show you the DROP DOWN list when you click on
  52.       the 'three dots' of the .RecordSource property of a Data Control.
  53.  
  54.    3. Xf$Location is the complete drive id + path + file name of the
  55.       btrieve file. Since Xf$Name is UNIQUE, VB3 can automatically use
  56.       this field to locate the Btrieve Table (file) you are trying to
  57.       access using Data Control or VB3 Data Access functions.
  58.  
  59.   B. FIELD.DDF, Length : 32
  60.      ----------------------
  61.  
  62.   File Name: X$Field (as it appears in the second entry of FILE.DDF)
  63.  
  64.  ┌Fld┬─ Field Name ──┬─Type──┬Size┐
  65.  │  1│Xe$Id          │Integer│   2│ <- Field ID starting from 1 (Unique)
  66.  │  2│Xe$File        │Integer│   2│ <- File ID (Xf$ID in FILE.DDF)
  67.  │  3│Xe$Name        │String │  20│ <- Field Name (May have duplicates)
  68.  │  4│Xe$DataType    │Integer│   1│ <- Field Type (0-13). See below
  69.  │  5│Xe$Offset      │Integer│   2│ <- Field Offset starting from 0
  70.  │  6│Xe$Size        │Integer│   2│ <- Field Size
  71.  │  7│Xe$Dec         │Integer│   1│ <- Field decimal places (for Decimal type)
  72.  │  8│Xe$Flags       │Integer│   2│ <- Reserved
  73.  └───┴───────────────┴───────┴────┘
  74.  
  75.  ┌Key┬─ Type ───┬─ Field ─┬Size┬─ Order ─┐
  76.  │  0│Unique    │1 Xe$Id  │   2│Ascending│
  77.  ├───┼──────────┼─────────┼────┼─────────┤
  78.  │  1│Non-unique│2 Xe$File│   2│Ascending│
  79.  ├───┼──────────┼─────────┼────┼─────────┤
  80.  │  2│Non-unique│3 Xe$Name│  20│Ascending│
  81.  ├───┼──────────┼─────────┼────┼─────────┤
  82.  │  3│Unique    │2 Xe$File│   2│Ascending│
  83.  │   │          │3 Xe$Name│  20│Ascending│
  84.  └───┴──────────┴─────────┴────┴─────────┘
  85.  
  86.  NOTES:
  87.  
  88.    1. 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 one 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. Message 2: As it appeared during VB3 beta:
  146.  
  147.   Here is a quick way to create DDF files w/o spending a single penny.
  148.   Download the file DDF.ZIP from LIB 1. This file contains following
  149.   files:
  150.  
  151.   1. FILE.DDF
  152.   2. FIELD.DDF
  153.   3. FILES.DAT
  154.   4. FIELDS.DAT
  155.  
  156.   FILE.DDF has five records. 1st three, as you know by now, are for the
  157.   dictionary files (FILE.DDF, FIELD.DDF and INDEX.DDF).
  158.  
  159.   Record 4 is for FILES.DAT. FILES.DAT is a minimal FILE.DDF i.e.
  160.   with only three records (for the three dictionary files).
  161.  
  162.   Record 5 is for FIELDS.DAT. FIELDS.DAT is minimal FIELD.DDF i.e.
  163.   with only 17 records (for the three dictionary files).
  164.  
  165.   Copy all these files into your VB3 subdirectory.
  166.   Now comes the bootstrap process i.e. use DDF files and VB3 to create your
  167.   DDF files.
  168.  
  169.   Use VISDATA.MAK project. Connect to Btrieve Data Base. Select FILE.DDF
  170.   from VB3 subdir. You will see two tables (i) 'My Files' and (ii) 'My Fields'.
  171.   Select Data Control Option and OPEN My Files Table. Start adding your
  172.   own Btrieve Files Names and Location. Assign Xf$ID starting from 4.
  173.  
  174.   Once you are done with all your Btrieve Files, OPEN 'My Fields' Table and
  175.   start adding the Fields of your Btrieve files that you just entered. You
  176.   might want to open two windows and add files in 'My Files' Table and fields
  177.   in 'My Fields' Tables at the same time. For 'My Files' table start Xe$ID
  178.   from 18.
  179.  
  180.   Note: There are some bugs in the VISDATA.MAK. Ignore 'Record x of y'
  181.         display inside the Data Control. It is not always right.
  182.         Do not worry if you make mistakes. You can always delete a record
  183.         and reenter with the same Xf$ID (or Xe$ID).
  184.  
  185.   When you are done rename FILE.DDF and FIELD.DDF to something else and
  186.   FILES.DAT to FILE.DDF and FIELDS.DAT to FIELD.DDF and you are on
  187.   your way to use VB3's data access methods and control with Btrieve.
  188.   And remember you can always add new files (tables) and delete the one
  189.   you don't need using the same process described above. I wish VB3 allowed
  190.   a file name other than FILE.DDF in the .DataBaseName property. Even though
  191.   manual says so VB3 ignores the file name you enter after the last "\" in
  192.   this property and always opens file FILE.DDF. If this was true then renaming
  193.   won't be necessary and adding and deleting tables will become a matter just
  194.   of using VISDATA.MAK.
  195.  
  196.   It might seem to like a tedious task to enter all these fields but the
  197.   rewards you will reap when you are done are astounding. VB3 Data Access
  198.   is deceptively simple yet enormously powerful.
  199.  
  200. ***************************************************************************
  201. Message 3: As it appeared during VB3 beta:
  202.  
  203.   Three ways of creating your DDF files are:
  204.  
  205.   1. VISDATA.MAK project from VB3
  206.   2. write your own program with Data Controls in VB3
  207.   3. Use MS Access to create the DDF files using the FILE.DDF, FIELD.DDF,
  208.   FILE.DAT and FILED.DAT files included in the DDF1.ZIP.
  209.  
  210.                     **** WARNING **** WARNING ****
  211.  
  212.   YOU MUST COPY ALL FILES TO 'C:\VB3' SUBDIR BEFORE YOU CAN USE ANY ONE OF
  213.   THE ABOVE THREE METHODS OF CREATING DDF FILES.
  214.  
  215.   I have included DB1.MDB database that is attached to Btrieve Tables
  216.   File_DDF (i.e. FILE.DAT) and Field_DDF (i.e. FIELD.DAT) that can be
  217.   used with MS Access. MS Access tables are easier to use than
  218.   VISDATA.MAK program for data entry.
  219.  
  220.   As explained in my previous messages FILE.DDF and FIELD.DDF contain
  221.   information about FILE.dat and FIELD.dat. You use one of the three
  222.   methods listed above to populate FILE.dat and FIELD.dat further with
  223.   the information about your Btrieve files and when done rename/copy
  224.   them to FILE.DDF and FIELD.DDF that can be used with VB3 or MS Access
  225.   to access your Btrieve files.
  226.  
  227.   Use DB1.MDB with ACCESS or use FILE.DDF with VISDATA.MAK.
  228.   As stated before, MS Access is easier to use then VISDATA.MAK because
  229.   it allows you to enter data in a grid like control (DataSheet).
  230.  
  231.   Don't you wish GRID control was Data aware with direct data entry into
  232.   cells ? But I know why we don't get everything we ask for in VB.
  233.   Eventually we will, but by that time VB will VB 7.0 (like PDS). All VB
  234.   users would have upgraded VB 7 times. And then VB 7.0 will get
  235.   replaced by something called 'Invisible Basic' and all of us here will
  236.   start Beta testing this new 'Invisible Basic' asking for new features
  237.   that we won't get and the whole cycle will start again. You and I will
  238.   get old (out dated) and our kids (poor souls) will get in this viscous
  239.   cycle of 'asking, not getting, getting eventually and then starting all
  240.   over again'. What a life !
  241.  
  242. Sunil.
  243.  
  244. P.S. Data aware Grid controls are now available from Sheridan Software and
  245.      FarPoint. Both are VERY good.
  246.  
  247.      I have uploaded DDF1.ZIP file in this forum and asked the Sysop to
  248.      make it public.
  249.  
  250.      I have also developed a VB module that uses WBTRCALL.DLL from Novell
  251.      to access Btrieve files from VB/VBA. This approach does not require
  252.      DDF files. Its is also somewhat faster than VB3's data access methods
  253.      and controls. But as usual you need to declare user type for every
  254.      Btrieve file you use. if you use VB3's data access you don't need any
  255.      user types to access the fields in your Btrieve files. In fact it is
  256.      not straight forward to copy record pointed by BookMark property to
  257.      an user defined type record variable. If you need it let me know.
  258.  
  259.      I wish VB3 allowed something similar to
  260.  
  261.      Lset MyTypeVar = Data1.RecordSet.BookMark
  262.  
  263.      to copy the entire record. May be VB4 will.
  264.  
  265.