home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 September / Chip_2000-09_cd1.bin / sharewar / Slunec / app / 16 / DATABASE.SWG / 0005_XBASE.pas < prev   
Pascal/Delphi Source File  |  1997-05-11  |  58KB  |  1,387 lines

  1.                #### ####   ######
  2.                 ##   ##    ##   ##
  3.                  ## ##     ##   ##  ######    ######   #####
  4.                   ###      ######        ##  ##       ##   ##
  5.                  ## ##     ##   ##  #######  ######## #######
  6.                 ##   ##    ##   ## ##    ##        ## ##
  7.                #### ####   ######   ######## #######   #####
  8.  
  9.                        Xbase file format description
  10.  
  11.                                     by
  12.  
  13.                                Erik Bachmann
  14.                           Clickety Click Software
  15.  
  16.                                 1997-03-10
  17.  
  18. WHAT IS XBASE
  19.  
  20.      "Generic term for the dBASE family of database languages. Coined in
  21.      response to threatened litigation over use of the copyrighted
  22.      trademark 'dBASE'."
  23.           http://wombat.doc.ic.ac.uk/
  24.  
  25. Xbase is a complex of data files, indexes and eventually note files for
  26. storing large amounts of formatted data in a structured form.
  27.  
  28. Basically Xbase is three different types of files:
  29.  
  30.      NN.dbf
  31.           Data files
  32.      NN.dbt
  33.           Memo files (i.e. a separate file containing full text fields)
  34.      *.ndx
  35.           Index files pointing to a field in the *.dbf
  36.  
  37. Xbase is almost compatible with dBASE and is actually a clone of dBASE. The
  38. creator of dBASE Ashton-Tate (and later Borland) has the copyright for the
  39. name dBASE, but NOT the structure.
  40. Therefore the name Xbase (It smells like - but it's not :-) has been widely
  41. used for look-alike data structures.
  42. There has been an attempt to create a standard for Xbase. I've found a lot
  43. of dead links while searching on Alta Vista's World Wide Web search engine.
  44.  
  45. I'm at the moment not aware of the result of the Xbase comityÆs work.
  46.  
  47. Xbase has - like most dBASE clones - it's offspring in the dBASE III+ file
  48. structure. I've tried to add all later enhancements as notes to the
  49. structure.
  50.  
  51. ---------------------------------------------------------------------------
  52.  
  53. Index
  54.  
  55.    * Top of document
  56.    * WHAT IS XBASE
  57.    * Index
  58.    * WHY THIS DOCUMENT
  59.    * WHAT SORT OF DATA CAN BE HANDLED
  60.    * WHAT DO THE FILES LOOK LIKE
  61.    * The structure of data files (*.dbf)
  62.    * What to check when opening a .DBF File
  63.    * The Structure of Index files
  64.    * Search algorithm for index files
  65.    * The Structure of Memo Field Files (*.dbt)
  66.    * The Structure of Memmory Files (*.mem)
  67.    * The Structure of Clipper Index Files (*.ntx)
  68.    * The Record Lock Field on a dBASE IV Table
  69.    * Read/write locks using share
  70.    * dBASE II FILES
  71.    * The structure of dBASE II data files (*.dbf)
  72.    * The Structure of dBASE II index file
  73.    * Examples
  74.    * Description of test.dbf
  75.    * Description of test.ndx
  76.    * Description of test.dbt
  77.    * Hex dump of test.dbf
  78.    * Hex dump of test.ndx
  79.    * Hex dump of test.dbt
  80.    * dBASE Specifications
  81.    *
  82.    * HISTORY
  83.    * REFERENCE LIST
  84.  
  85. ---------------------------------------------------------------------------
  86.  
  87. WHY THIS DOCUMENT
  88.  
  89. I've been looking for a simple database tool for my work with C programming
  90. and bibliographical database systems. During my investigation of a lot of
  91. BBS's, FTP sites, toolboxes etc. I've discovered at lot of
  92. almost-ready-to-fly Xbase clones. This made me wonder why no one has
  93. collected a description of Xbase files AND made a simple package of C
  94. functions to handle this type of data files.
  95. THAT was my goal - and THIS is the result.
  96.  
  97. ---------------------------------------------------------------------------
  98.  
  99.            NOTICE ! ! !
  100.   .----.
  101.  ((*)(*))  DO *NOT*
  102.   \ /\ /        attempt to manipulate any critical database files
  103.    ####         *WITHOUT* making a proper and validated backup first.
  104.    \__/    DO *NOT*
  105.                 access any database files in a multi-user environment!
  106.  
  107. ---------------------------------------------------------------------------
  108.  
  109. Any comments, corrections, additions etc. are welcome. You can reach me at:
  110. e_bachmann@geocities.com
  111. or by snail mail:
  112.  
  113.      Erik Bachmann, Grydeh°jvej 62, DK-4000 Roskilde, Denmark, Europe
  114.  
  115. Third stone from the Sun - and turn left :-)
  116.  
  117. ---------------------------------------------------------------------------
  118.  
  119. WHAT SORT OF DATA CAN BE HANDLED
  120.  
  121. Data files (*.dbf) contains a header with information on the data structure
  122. AND the record themselves. The data field is predefined as carrying data of
  123. a specific type ( Character, Numbers, Longs, Dates, Memo).
  124. Each data type has its limitations:
  125.  
  126.              ASCII text < 254 characters long. Character fields can be up to
  127. C  Character 32 KB long (in Clipper and FoxPro) using decimal count as high
  128.              byte in field length. It's possible to use up to 64KB long
  129.              fields by reading length as unsigned.
  130.  
  131. N  Number    ASCII text 18 characters long. Number fields can be up to 20
  132.              characters long in FoxPro and Clipper.
  133.              Boolean/byte (8 bit) Legal values:
  134.              ?    Not initialised (default)
  135.              Y,y  Yes
  136.              N,n  No
  137. L  Logical   F,f  False
  138.              T,f  True
  139.              Logical fields are always displayed using
  140.              T/F/?. Some sources claims that space (ASCII
  141.              20h) is valid for not initialised.
  142. D  Date      Date in format YYYYMMDD. A date like 0000-00- 00 is *NOT* valid.
  143.  
  144. M  Memo      Pointer to ASCII text field in memo file 10 digits representing
  145.              a pointer to a DBT block (default is blanks).
  146.  
  147. F  Floating  (dBASE IV and later, FoxPro, Clipper) 20 digits
  148.    point
  149.    Character
  150. N/Aname      1-254 characters (64 KB in FoxBase and Clipper)
  151.    variable
  152. B  Binary    (dBASE V) Like Memo fields, but not for text processing.
  153. G  General   (dBASE V: like Memo) OLE Objects in MS Windows versions
  154. P  Picture   (FoxPro) Like Memo fields, but not for text processing.
  155.  
  156. Index files (*.ndx) are sorted references to fields in the data files.
  157. There might be more than one index for each data file.
  158.  
  159. dBASE III Memo files are primitive 512 byte hunks of ASCII text data
  160. creating a way for text fields to exceed the 255 characters barrier of
  161. ordinary text fields. Other versions may store up till 64 KB of text in a
  162. fixed sized text field. Larger amounts of text (and binary data) is still
  163. stored in memo-like files. The size off the blocks can be user defined
  164. while creating the memo file (see byte 4-7 of the memo file structure).
  165.  
  166. ---------------------------------------------------------------------------
  167.  
  168. WHAT DO THE FILES LOOK LIKE
  169.  
  170. They all look brown to me :-)
  171. All Xbase files have a header describing the structure of the data in the
  172. file.
  173.  
  174. Schematically they look like this:
  175.  
  176. The structure of data files (*.dbf)
  177.  
  178.     _______________________  _______
  179.  0 | Version number      *1|  ^
  180.    |-----------------------|  |
  181.  1 | Date of last update   |  |
  182.  2 |      YYMMDD           |  |
  183.  3 |                       |  |
  184.    |-----------------------|  |
  185.  4 | Number of records     | Record
  186.  5 | in data file          | header
  187.  6 | ( 32 bits ) *14       |  |
  188.  7 |                       |  |
  189.    |-----------------------|  |
  190.  8 | Length of header      |  |
  191.  9 | structure ( 16 bits ) |  |
  192.    |-----------------------|  |
  193.  10| Length of each record |  |
  194.  11| ( 16 bits )         *2|  |
  195.    |-----------------------|  |
  196.  12| ( Reserved )        *3|  |
  197.  13|                       |  |
  198.    |-----------------------|  |
  199.  14| Incomplete transac.*12|  |
  200.    |-----------------------|  |
  201.  15| Encryption flag    *13|  |
  202.    |-----------------------|  |
  203.  16| ( Reserved for        |  |            _  |=======================| _______
  204.    |   multi-user dBASE )  |  |           /  0| Field name in ASCII   |  ^
  205.    : ( dBASE III+ - )      :  |          /    : (terminated by 00h)   :  |
  206.    :                       :  |         |     |                       |  |
  207.  27|                       |  |         |   10|                       |  |
  208.    |-----------------------|  |         |     |-----------------------| For
  209.  28| MDX flag (dBASE IV) *4|  |         |   11| Field type in ASCII   | each
  210.    |-----------------------|  |         |     |-----------------------| field
  211.  29| Language driver     *5|  |        /    12| Field data address    |  |
  212.    |-----------------------|  |       /       |                     *6|  |
  213.  30| ( Reserved )          |  |      /        | (in memory !!!)       |  |
  214.  31|                     *3|  |     /       15| (dBASE III+)          |  |
  215.    |=======================|__|____/          |-----------------------|  | <-
  216.  32|                       |  |  ^          16| Field length  (binary)|  |   |
  217.    |- - - - - - - - - - - -|  |  |            |-----------------------|  |   | *7
  218.    |                       |  |  |          17| Decimal count (binary)|  |   |
  219.    |- - - - - - - - - - - -|  |  Field        |-----------------------|  | <-
  220.    |                       |  | Descriptor  18| ( Reserved for        |  |
  221.    :. . . . . . . . . . . .:  |  |array     19|   multi-user dBASE )  |  |
  222.    :                       :  |  |            |-----------------------|  |
  223. n  |                       |__|__v_         20| Work area ID          |  |
  224.    |-----------------------|  |    \          |-----------------------|  |
  225. n+1| Terminator (0Dh)      |  |     \       21| ( Reserved for        |  |
  226.    |=======================|  |      \      22|   multi-user dBASE )  |  |
  227. m  | Database Container    |  |       \       |-----------------------|  |
  228.    :                *15    :  |        \    23| Flag for SET FIELDS   |  |
  229.    :                       :  |         |     |-----------------------|  |
  230. m+263                      |  |         |   24| ( Reserved )          |  |
  231.    |=======================|__v_ ___    |     :                       :  |
  232.    :                       :    ^       |     :                       :  |
  233.    :                       :    |       |   30|                       |  |
  234.    | Record structure      |    |       |     |-----------------------|  |
  235.    |                       |    |        \  31| Index field flag    *8|  |
  236.    |                       |    |         \_  |=======================| _v_____
  237.    |                       | Records
  238.    |-----------------------|    |
  239.    |                       |    |          _  |=======================| _______
  240.    |                       |    |         /  0| Field deleted flag  *9|  ^
  241.    |                       |    |        /    |-----------------------|  |
  242.    |                       |    |       /     | Data               *10|  One
  243.    |                       |    |      /      :                       : record
  244.    |                       |____|_____/       |                       |  |
  245.    :                       :    |             |                       | _v_____
  246.    :                       :____|_____        |=======================|
  247.    :                       :    |     \       | Field deleted flag  *9|
  248.    |                       |    |      \      |-----------------------|
  249.    |                       |    |       \     |                       |
  250.    |                       |    |        \    |                       |
  251.    |                       |    |         \_  |-----------------------|
  252.    |                       |    |
  253.    |=======================|    |
  254.    |__End_of_File__________| ___v____  End of file ( 1Ah )  *11
  255.  
  256. *1
  257.      dBASE III+:
  258.      03h file without DBT. 83h file with DBT. i.e. bit 0-3 version, 3-5
  259.      SQL, 7 DBT flag
  260.      dBASE IV:
  261.           bit
  262.           0-2
  263.                Version no.
  264.           3
  265.                Presence of memo file
  266.           4-6
  267.                Presence of SQL table
  268.           7
  269.                DBT flag
  270.  
  271. Examples:
  272.  
  273. 03h
  274.      dBASE III w/o memo file
  275. 04h
  276.      dBASE IV or IV w/o memo file
  277. 05h
  278.      dBASE V w/o memo file
  279. 83h
  280.      dBASE III+ with memo file
  281. F5h
  282.      FoxPro w. memo file
  283. 8Bh
  284.      dBASE IV w. memo
  285. 8Eh
  286.      dBASE IV w. SQL table
  287. 30h
  288.      Visual FoxPro w. DBC
  289. *2
  290.      Sum of lengths of all fields + 1 (deletion flag)
  291. *3
  292.      (dBASE IV) Filled with 00h.
  293. *4
  294. (dBASE IV) Production index / Multiple index file
  295.      01h MDX file present
  296.      00h no MDX file (index upon demand).
  297. (FoxBase)
  298.      01h CDX compound index file present,
  299.      00h no CDX file.
  300. (Visual FoxPro)
  301.      02h With memo
  302.      04h Database Container (DBC)
  303.      07h DBC (incl. memo & indexes)
  304. *5
  305.      (Foxpro) Code page:
  306.  
  307. 01hDOS USA          code page 437
  308. 02hDOS Multilingual code page 850
  309. 03hWindows ANSI     code page 1251
  310. C8hWindows EE       code page 1250
  311.  
  312. *6
  313.      (FoxPro) 12-13. offset of field from beginning of record.
  314. *7
  315.      (FoxPro, Clipper)
  316.      16-17: Field length for non-numerical fields. Byte 16 is normally
  317.      field length (0-255) and byte 17 represents the high byte for field
  318.      length (256-65535).
  319. *8
  320.      (dBASE IV) Index field flag:
  321. 00h
  322.      No key for this field
  323. 01h
  324.      Key exists for this field
  325. *9
  326.      2Ah record is deleted, 20h record is NOT deleted
  327. *10
  328.      There are no field separators for record terminators.
  329. *11
  330.      dBASE II regards any End-of-File 1Ah value as the end of the file.
  331.      dBASE III regard an End-of-File as an ordinary character, however it
  332.      appends an extra End-of-File character at the physical end of the
  333.      file.
  334. *12
  335.      (dBASE IV) Incomplete transaction 00h Transaction ended (or rolled
  336.      back) 01h Transaction started
  337. *13
  338.      (dBASE IV) Encryption flag 00h Not encrypted 01h Data encrypted
  339. *14
  340.      Stored at binary i.e. value is generated as: byte#1 + (byte#2 * 256) +
  341.      (byte#3 * 256²) + (byte#4 * 256³) .......
  342. *15
  343.      (Visual FoxPro) Database Container (DBC) 263 bytes for backlist.
  344.      Included in header structure.
  345.  
  346. ---------------------------------------------------------------------------
  347.  
  348. What to check when opening a .DBF File
  349.  
  350. Records:
  351.  
  352.    * Length of record must be > 1 and < max length. (max length = 4000 B in
  353.      dBASE III and IV, can be 32KB in other systems).
  354.    * The number of records must be >= 0.
  355.  
  356. Fields:
  357.  
  358.    * The .DBF file must have at least one field.
  359.    * The number of fields must be <= the maximum allowable number of
  360.      fields.
  361.  
  362. File size:
  363.  
  364.    * File size reported by the operating system must match the logical file
  365.      size.
  366.      Logical file size = ( Length of header + ( Number of records * Length of each record ) )
  367.  
  368. ---------------------------------------------------------------------------
  369.  
  370. The Structure of Index files
  371.  
  372. The index file is a B+ tree. The essential structure is in an inverted
  373. tree, with an anchor note, multiple root nodes, and leaf nodes. The header
  374. is called the anchor node.
  375.  
  376. ---------------------------------------------------------------------------
  377.  
  378.  NOTE!   Normally the header is read once only by the application, when
  379.          the file is opened.
  380.  
  381. ---------------------------------------------------------------------------
  382.  
  383. The size of a page is ( as far as I know ) always 512 bytes.
  384.  
  385.     _______________________  _______
  386.  0 | Starting page no      |  ^
  387.  1 |                       |  |
  388.  2 |                       |  |
  389.  3 |                       |  |
  390.    |-----------------------|  |
  391.  4 | Total no of pages     | File
  392.  5 |                       | header
  393.  6 |                       |  |
  394.  7 |                       | (page 0)
  395.    |-----------------------|  |
  396.  8 | (Reserved)            |  |
  397.  9 |                       |  |
  398. 10 |                       |  |
  399. 11 |                       |  |
  400.    |-----------------------|  |
  401. 12 | Key length            |  |
  402. 13 |                       |  |
  403.    |-----------------------|  |
  404. 14 | No of keys per page   |  |
  405. 15 |                       |  |
  406.    |-----------------------|  |
  407. 16 | Key type: 0 = char    |  |
  408. 17 |           1 = Num     |  |
  409.    |-----------------------|  |
  410. 18 | Size of key record    |  |
  411. 19 |                       |  |
  412. 20 |                       |  |
  413. 21 |                       |  |
  414.    |-----------------------|  |
  415. 22 | (Reserved)            |  |
  416.    |-----------------------|  |
  417. 23 | Unique flag           |  |
  418.    |-----------------------|  |
  419. 24 | String defining the   |  |
  420.    | key                   |  |
  421.    :                       :  |           __  |=======================|
  422.    :                       :  |          /   0| Pointer to lower level|
  423.    |                       |  |         /    1| (next page)           |
  424. 511|                       |  |        /     2|                       |
  425.    |=======================| _v_____  /      3|                       |
  426.   0|                       |  ^      /        |-----------------------|
  427.   1|                       | _|_____/        4| Record number in      |
  428.   2| Array of key entries  |  |              5| data file             |
  429.   3|                       | Page            6|                       |
  430.   4|                       |  |              7|                       |
  431.    |                       |  |               |-----------------------|
  432.    |                       | _|_____         8| Key data              |
  433.    :                       :  |     \         :                       :
  434.    :                       :  |      \       N|                       |
  435. 511|                       |  |       \_____  |=======================|
  436.    |=======================| _v_____
  437.  
  438. ---------------------------------------------------------------------------
  439.  
  440. Search algorithm for index files
  441.  
  442.   1. The anchor node always resides in memory, while the file is open and
  443.      determines which root node to access for at given key.
  444.   2. The root node is read and sequentially scanned until a key is found
  445.      that is >= to the desired key.
  446.   3. A second-level node is accessed and scanned in a manner similar to the
  447.      root node.
  448.   4. The process continues until the pointer to the next-lower-level node
  449.      has a value of zero. If the key matches the leaf key at this level,
  450.      the record number for the key is returned.
  451.      That's a discipline NOT to be discussed here :-) Way out of the scope
  452.      fore this document and way too complex.
  453.  
  454. One of the advances of the B+ tree is that the higher levels of the tree
  455. does not have to be updated when a certain node is changed - unless the
  456. tree has become unbalanced.
  457.  
  458. ---------------------------------------------------------------------------
  459.  
  460. The Structure of Memo Field Files (*.dbt)
  461.  
  462.     _______________________  _______
  463.  0 | Number of next        |  ^  ^
  464.  1 | available block       |  |  |
  465.  2 | for appending data    |  | Header
  466.  3 | (binary)              |  |  |
  467.    |-----------------------| _|__v__
  468.  4 | ( Reserved )          |  |
  469.    | Size of blocks     *1 |  |
  470.    |                       |  |
  471.  7 |                       |  |
  472.    |-----------------------|  |
  473.  8 | ( Reserved )          |  |
  474.    |                       |  |
  475.    | (i.e. garbage)        |  |
  476.    :                       : First block
  477.    :                       :  |
  478. 511|                       |  |
  479.    |=======================| _v_____
  480. 512|                       |  ^
  481.    |                       |  |
  482.    |                       | 512 Bytes
  483.    |                       | text blocks
  484.    :                       :  |
  485.    :                       :  |
  486.    |                       |  |
  487.    |-----------------------| _|_____
  488.    | Field terminator (1Ah)|  |  ^
  489.    |-----------------------|  |  |Terminating field
  490.    | Field terminator (1Ah)|  |  |within the block
  491.    |-----------------------| _|__v__
  492.    : ( Unused )            :  |
  493. 1023                       :  |
  494.    |=======================| _v_____
  495.    |                       |  ^
  496.    |                       |  |
  497.    |                       | 512 Bytes
  498.    |                       | text blocks
  499.    :                       :  |
  500.    :                       :  |
  501.    |                       |  |
  502.    |                       | _v_____
  503.    |=======================|
  504.  
  505. *1)
  506.      (FoxBase, dBASE IV ??) Size of blocks in memo file (SET BLOCKSIZE).
  507.      Default is 512 bytes.
  508.  
  509. A memo field can be longer than the 512 byte block. It simply continues
  510. through the next block. The field is logically terminated by two
  511. End-of-file marks in the field. The reminder of the block is unused.
  512.  
  513. ---------------------------------------------------------------------------
  514.  
  515. NOTE!
  516. Every time you re-write a memo field to the memo file in dBASE the field is
  517. APPENDED to the memo file (i.e. the file expands for each update). dBASE V
  518. for DOS (and perhaps others) may reuse the space from the deleted text.
  519.  
  520. ---------------------------------------------------------------------------
  521.  
  522. The Memo file itself tells nothing about it's use. You need the
  523. corresponding DBF file to interpret the content of the memo file. Many of
  524. the clones and dBASE 5 have binary elements stored in the memo file marked
  525. with file type B or G.
  526.  
  527. ---------------------------------------------------------------------------
  528.  
  529.   .----.
  530.  ((*)(*))  NOTICE ! ! !
  531.   \ /\ /
  532.    ####    DO *NOT*
  533.    \__/         attempt to treat these binary data as simple text ! ! !
  534.  
  535. ---------------------------------------------------------------------------
  536.  
  537. ---------------------------------------------------------------------------
  538.  
  539. The Structure of Memmory Files (*.mem)
  540.  
  541.     _______________________  _______
  542.  0 |                       |  ^  ^
  543.  1 | A null-terminated     |  |  |
  544.    : string containing     :  | Header
  545.  9 | the variable name     |  |  |
  546. 10 |                       |  |  |
  547.    |-----------------------| _|__v__
  548. 11 | Variable type         |  |
  549.    |-----------------------|  |
  550. 12 | ( Reserved )          |  |
  551.    :                       :  |
  552. 15 |                       |  |
  553.    |-----------------------|  | <-
  554. 16 | Field length  (binary)|  |   |
  555.    |-----------------------|  |   | *1
  556. 17 | Decimal count (binary)|  |   |
  557.    |-----------------------|  | <-
  558. 18 | ( Reserved )          |  |
  559.    :                       :  |
  560.    :                       :  |
  561. 31 |                       | _v_____
  562.    |=======================|
  563.  
  564. *1
  565.      (FoxPro, Clipper)
  566.      16-17: Field length for non-numerical fields. Byte 16 is normally
  567.      field length (0-255) and byte 17 represents the high byte for field
  568.      length (256-65535).
  569.  
  570. ---------------------------------------------------------------------------
  571.  
  572. The Structure of Clipper Index files (*.ntx)
  573.  
  574. The CA-Clipper index file is a modified B+ tree. The size of a page is 1024
  575. bytes. The first page is the header:
  576.  
  577.      _______________________  _______
  578.  0  | Signature byte        |  ^
  579.  1  | 03h = Index file      |  |
  580.     |-----------------------|  |
  581.  2  | Indexing version no.  |  |
  582.  3  |                       |  |
  583.     |-----------------------|  |
  584.  4  | Offset in file for    | File
  585.  5  | first index page.     | header
  586.  6  |                       |  |
  587.  7  |                       | (page 0)
  588.     |-----------------------|  |
  589.  8  | Offset to an unused   |  |
  590.  9  | key page.             |  |
  591. 10  |                       |  |
  592. 11  |                       |  |
  593.     |-----------------------|  |
  594. 12  | Key size + 8 bytes    |  | *1
  595. 13  |                       |  |
  596.     |-----------------------|  |
  597. 14  | Key size              |  |
  598. 15  |                       |  |
  599.     |-----------------------|  |
  600. 16  | No. of decimals in    |  |
  601. 17  | key                   |  |
  602.     |-----------------------|  |
  603. 18  | Key expression.       |  |
  604. 19  | (NULL terminated)     |  |
  605.     :                       :  |
  606. 277 |                       |  |
  607.     |-----------------------|  |
  608. 278 | Unique index flag     |  | *3
  609.     |-----------------------|  |
  610. 279 | (Unused)              |  |
  611.     :                       :  |
  612.     :                       :  |
  613. 1023|                       |  |
  614.     |=======================| _v_____
  615.    0|                       |    ^
  616.     :                       :    |
  617.     :                       :   Page
  618.     :                       :    |         __  |=======================|
  619.     :                       :    |        /   0| No. of used entries   |*4
  620.     |                       |    |       /    1| on current page       |
  621.     |                       |    |      /      |-----------------------|
  622.     |                       |    |     /      2| Array of unsigned     |
  623.     |=======================| ___|____/       3| longs   *5            |
  624.     |                       |    |             :                       :
  625.     :                       :    |             :                       :
  626.     :                       : ___|____         :                       :
  627.     |=======================|    |    \       N|                       |
  628.     |                       |    |     \_____  |=======================|
  629.     :                       :    |
  630.     |__End_of_File__________| ___v____  End of file ( 1Ah )
  631.  
  632. *1
  633.      (Clipper)
  634.      Distance between key pages.
  635. *2
  636.      (Clipper)
  637.      The first, or root page of an indes has a minimum of 1 entry
  638.      regardless of this value.
  639. *3
  640.      (Clipper)
  641.      1: Unique
  642.      0: NOT unique
  643. *4
  644.      (Clipper)
  645.      This number will bi between the minimum and maximum defined in the
  646.      header unless it is the root page.
  647. *5
  648.      (Clipper)
  649.      The array length is ewual to the maximum number of key entries per
  650.      page +1.
  651.  
  652. ---------------------------------------------------------------------------
  653.  
  654. ---------------------------------------------------------------------------
  655.  
  656. The Record Lock Field on a dBASE IV Table
  657.  
  658. In a DOS multiuser environment, each user can place record locks on a
  659. shared table. For example, if user JSMITH is editing record number 12 of
  660. Stock, user MBROWN cannot access that record until it is unlocked. This
  661. prohibits one user from unintentionally overwriting another user's work.
  662.  
  663. The dBASE table type gives you the Record Lock option to show you
  664. information about a locked record. If you check Record Lock, Database
  665. Desktop adds a hidden character field named _DBASELOCK to the table. This
  666. field shows you when a record was locked and by whom.
  667.  
  668. ---------------------------------------------------------------------------
  669.  
  670. NOTE:
  671. Although Database Desktop adds the Record Lock field to the table, you will
  672. not see it when you view the table. You see a record's Record Lock field
  673. only if you are locked out of that record.
  674.  
  675. ---------------------------------------------------------------------------
  676.  
  677. Use the Create dBASE Table dialogue box to create the Record Lock field for
  678. a dBASE table. Record Lock is not available for dBASE III+ tables.
  679.  
  680. The information you see when you find a locked field depends on the Info
  681. Size you specify. The Record Lock field can be from 8 to 24 characters. The
  682. default is 16.
  683.  
  684. 0-1
  685.      The first two bytes (binary integer) tell whether a user has changed
  686.      the record. Every committed change is counted encreasing the count by
  687.      one.
  688. 2-4
  689.      The next three characters tell the time a user placed the lock. (10h
  690.      09h 07h i.e. 16:09:07)
  691. 5-7
  692.      The next three characters tell the date a user placed the lock. ( 60h
  693.      09h 0Bh i.e. (19)96-09-11 )
  694. 8-24
  695.      The remaining 16 characters are optional. They tell the name of the
  696.      user that placed the lock.
  697.  
  698. The default size of 16 displays the changed status of the record, the time
  699. and date of the lock, and the first 8 characters of the user who placed the
  700. lock.
  701.  
  702. ---------------------------------------------------------------------------
  703.  
  704. NOTE!
  705.  
  706.      You cannot see from the locking info if the user releases the
  707.      record again. You have to test the record locking.
  708.  
  709.      On DOS systems SHARE has to be loaded. Turbo C, DJGPP and
  710.      compatible C compilers have functions like:
  711.  
  712.           lock()
  713.           _dos_lock()
  714.           locking() for setting locks on a region of a file
  715.  
  716.           and
  717.  
  718.           unlock()
  719.           _dos_unlock()
  720.           unlocking for removing the lock again.
  721.  
  722.           It's important that YOU remove the locks BEFORE closing the
  723.           file.
  724.  
  725. ---------------------------------------------------------------------------
  726.  
  727. Read/write locks using share
  728.  
  729. by Phil Barnett (philb@iag.net)
  730.  
  731. Share holds the locks, but it doesn't know anything about the structure or
  732. program that is requesting the lock. All share does is record the lock
  733. offset, type (record or file) and file name with path and where (station)
  734. it came from, and remove it when the correct station requests removal.
  735.  
  736. Lets make a scenario.
  737.  
  738. You have a 1000 byte header on your dbf file, and each record is 99 bytes +
  739. one for the delete flag. (this is to make the math simple)
  740.  
  741. If you locked record one at the actual offset it would lock a range from
  742. byte 1001 to 1100.
  743.  
  744. Any other station requesting READ or WRITE would be denied. Of course, we
  745. can read through locks in xBase, so how do they do it?
  746.  
  747. The xBase languages add an arbitrary number to the actual offset.
  748. Originally, Clipper used 1,000,000,000 + record offset. Fox used another
  749. offset, and I am not sure but I think it was 4,000,000,000.
  750.  
  751. We'll call this huge number the Lock Offset.
  752.  
  753. Later, Clipper changed the Lock Offset to the same as Fox for certain
  754. RDD's. (.CDX and .IDX)
  755.  
  756. For years, even though Clipper could create .NDX indexes, it was not Lock
  757. Offset compatible with dBase, and using both platforms on the same data
  758. caused incorrect locking.
  759.  
  760. The Lock Offset numbers are arbitrarily large to keep actual data files
  761. from crossing the limit. (hopefully, we aren't creating any 1 trillion byte
  762. files) (or 4 trillion for newer schemes)
  763.  
  764. So, in an xBase file, record locks and writes are at Lock Offset + File
  765. Offset and reads are at File Offset, so they do not run into a lock. This
  766. allows "read through"
  767.  
  768. Locks between xBase systems are only able to be used concurrently when the
  769. arbitrary Lock Offset is the same in both systems.
  770.  
  771. So, in the above example, to lock the first record the Lock Offset would be
  772. 4,000,001,001 to 4,000,001,100.
  773.  
  774. If both languages used the same offset, then the write lock would be
  775. correctly enforced.
  776.  
  777. ---------------------------------------------------------------------------
  778.  
  779. These offsets are mentioned in online documentation (for CA-Clipper) (read
  780. 52eint.txt or clip53a.txt). The 1,000,000+RECNO() is used as default. If
  781. you want to use offset 4,000,000 you have to link the ntxlock2.obj file.
  782. For CDX indexes you should link cdxlock.obj to be compatible with Fox
  783. locking scheme (but only for Clipper != 5.2e)
  784. Confirmed by: r(ycho)GLAB, VIP Software (rglab@waw.pdi.net)
  785.  
  786. ---------------------------------------------------------------------------
  787.  
  788. For more information on record locking read :
  789. "Transactional Locking, Part 1" by Thomas Wang (wang@cup.hp.com) on
  790. http://www.concentric.net/~Ttwang/tech/locks1.htm
  791.  
  792. ---------------------------------------------------------------------------
  793.  
  794. dBASE II FILES
  795.  
  796. The Structure of dBASE II data files (*.dbf)
  797.  
  798.     _______________________  _______
  799.  0 | Version number      *1|  ^
  800.    |-----------------------|  |
  801.  1 | Number of records     | Record
  802.  2 | in data file (16 bit) | header
  803.    |-----------------------|  |            _  |=======================| _______
  804.  3 | Date of last update   |  |           /  0| Field name in ASCII   |  ^
  805.  4 |      YYMMDD           |  |          /    : (terminated by 00h)   :  |
  806.  5 |                       |  |         |     |                       |  |
  807.    |-----------------------|  |         |   10|                       |  |
  808.  6 | Length of each record |  |         |     |-----------------------| For
  809.  7 | ( 16 bits )         *2|  |         |   11| Field type in ASCII *4| each
  810.    |-----------------------|--|---      |     |-----------------------| field
  811.  8 |                       |  |  ^      |   12| Field length  (binary)|  |
  812.  9 | Field descriptor      |  |  | ____/      |-----------------------|  |
  813.    : Array                 :  |  |          13| Field adress in memory|  |
  814.    : (Terminated by 0Dh)   :  |  |          14|                       |  |
  815.    :                       :  |  | ______     |-----------------------|  |
  816.    :                       :  |  |       \  15| Field decimal count   |  |
  817.    :                       :  |  |        \_  |=======================| _v_____
  818.    |                       |  |  |
  819. 519|                       |  |  |
  820.    |-----------------------|  |  |
  821. 520| Terminator          *3|__v__v_
  822.    |=======================|    |
  823. 521| Records               |    |
  824.    :                       :    |
  825.    :                       :    |
  826.    :                       :    |
  827.    :                       :    |
  828.   n|                       |    |
  829.    |__End_of_File__________| ___v____  End of file ( 1Ah )  *11
  830.  
  831. *1
  832.      dBASE II version no: 02h
  833. *2
  834.      Sum of lengths of all fields + 1 (deletion flag)
  835. *3
  836.      0Dh if all 32 fields present, otherwise 00h.
  837. *4
  838.      Field type: C, N or L
  839.  
  840. ---------------------------------------------------------------------------
  841.  
  842. The Structure of dBASE II index file
  843.  
  844. This was previously presented as the structure of dBASE III index files.
  845. Checking with the actual header of an index made it obvious, that it did
  846. NOT fit with dBASE III index files ( In that case several of the most
  847. essential key fields should be NULL values ).
  848.  
  849.     _______________________  _______
  850.  0 | (Reserved)            |  ^
  851.  1 |                       |  |
  852.    |-----------------------|  |
  853.  2 | Node number of        |  |
  854.  3 | root node             |  |
  855.    |-----------------------|  |
  856.  4 | Node number of        | Anchor
  857.  5 | next available node   |  node
  858.    |-----------------------| description
  859.  6 | Length of key         |  |
  860.    |-----------------------|  |
  861.  7 | Size of key entry     |  |
  862.    |-----------------------|  |
  863.  8 | Maximum keys/node     |  |
  864.    |-----------------------|  |
  865.  9 | Field type            |  |
  866.    |-----------------------|  |
  867.  10| Key expression in     |  |
  868.    | ASCII                 |  |
  869.    :                       :  |
  870.    :                       :  |
  871.    |                       |  |
  872. 109| (00h terminated)      |  |
  873.    |-----------------------|  |
  874. 110| (Unused)              |  |
  875.    |                       |  |            _
  876.    :                       :  |           /   |=======================|
  877.    :                       :  |          /   0| Pointer to lower level|
  878.    |                       |  |         /    1| (next page)           |
  879. 511| ( 16 bits )           |  |        /      |-----------------------|
  880.    |=======================| _v_____  /      2| Record number         |
  881.   0| No.of keys in node    |  ^      /       3|                       |
  882.    |-----------------------| _|_____/         |-----------------------|
  883.   1| Array of key entries  |  |              4| Key expression        |
  884.    |                       | Index            |                       |
  885.    |                       | record           :                       :
  886.    |-----------------------| _|_____          :                       :
  887.    :                       :  |     \        N|                       |
  888. 511|                       |  |      \______  |=======================|
  889.    |=======================| _v_____
  890.  
  891. ---------------------------------------------------------------------------
  892.  
  893. Examples
  894.  
  895. Description of test.dbf
  896.  
  897. Name of data file      : test.dbf
  898. Version no.            : 5
  899. Memo file present      : 131
  900. No. of records         : 3
  901. Length of header       : 193
  902. Length of records      : 279
  903. Date for latest change : 19960814
  904. No. of fields          : 5
  905. Current record         : 0
  906. Crypted                : no
  907. mdx/cdx file           : no
  908. broken transaction     : no
  909.  
  910. Multi user information :  00 00 00 00 00 00 00 00 00 00 00 00 00
  911.  
  912. Field descriptions :
  913.   Name          Type    length  Decimal
  914. # ID            N       5       0
  915. # MSG           C       254     0
  916. # NOTE          M       10      0
  917. # BOOLEAN       L       1       0
  918. # DATES         D       8       0
  919.  
  920. Description of test.ndx
  921.  
  922. A index made on ID field in test.dbf
  923.  
  924. Description of test.dbt
  925.  
  926. A memo file containing the NOTE field from test.dbf
  927.  
  928. ---------------------------------------------------------------------------
  929.  
  930. 000000  83600811 03000000 C1001701 00000000  .`..............
  931. 000010  00000000 00000000 00000000 00000000  ................
  932. 000020  49440000 00000000 0000004E 0700DA3F  ID.........N...?
  933. 000030  05000000 01000000 00000000 00000000  ................
  934. 000040  4D534700 00000000 00000043 0C00DA3F  MSG........C...?
  935. 000050  FE000000 01000000 00000000 00000000  ................
  936. 000060  4E4F5445 00000000 0000004D 0A01DA3F  NOTE.......M...?
  937. 000070  0A000000 01000000 00000000 00000000  ................
  938. 000080  424F4F4C 45414E00 0000004C 1401DA3F  BOOLEAN....L...?
  939. 000090  01000000 01000000 00000000 00000000  ................
  940. 0000A0  44415445 53000000 00000044 1501DA3F  DATES......D...?
  941. 0000B0  08000000 01000000 00000000 00000000  ................
  942. 0000C0  0D202020 20203152 65636F72 64206E6F  .     1Record no
  943. 0000D0  20312020 20202020 20202020 20202020   1
  944. 0000E0  20202020 20202020 20202020 20202020
  945. 0000F0  20202020 20202020 20202020 20202020
  946. 000100  20202020 20202020 20202020 20202020
  947. 000110  20202020 20202020 20202020 20202020
  948. 000120  20202020 20202020 20202020 20202020
  949. 000130  20202020 20202020 20202020 20202020
  950. 000140  20202020 20202020 20202020 20202020
  951. 000150  20202020 20202020 20202020 20202020
  952. 000160  20202020 20202020 20202020 20202020
  953. 000170  20202020 20202020 20202020 20202020
  954. 000180  20202020 20202020 20202020 20202020
  955. 000190  20202020 20202020 20202020 20202020
  956. 0001A0  20202020 20202020 20202020 20202020
  957. 0001B0  20202020 20202020 20202020 20202020
  958. 0001C0  20202020 20202020 20202020 20203120                1
  959. 0001D0  31393936 30383133 2A202020 20324E6F  19960813*    2No
  960. 0001E0  20322020 20202020 20202020 20202020   2
  961. 0001F0  20202020 20202020 20202020 20202020
  962. 000200  20202020 20202020 20202020 20202020
  963. 000210  20202020 20202020 20202020 20202020
  964. 000220  20202020 20202020 20202020 20202020
  965. 000230  20202020 20202020 20202020 20202020
  966. 000240  20202020 20202020 20202020 20202020
  967. 000250  20202020 20202020 20202020 20202020
  968. 000260  20202020 20202020 20202020 20202020
  969. 000270  20202020 20202020 20202020 20202020
  970. 000280  20202020 20202020 20202020 20202020
  971. 000290  20202020 20202020 20202020 20202020
  972. 0002A0  20202020 20202020 20202020 20202020
  973. 0002B0  20202020 20202020 20202020 20202020
  974. 0002C0  20202020 20202020 20202020 20202020
  975. 0002D0  20202020 20202020 20202020 20202020
  976. 0002E0  20202020 20325931 39393630 38313420       2Y19960814
  977. 0002F0  20202020 334D6573 73616765 206E6F20      3Message no
  978. 000300  33202020 20202020 20202020 20202020  3
  979. 000310  20202020 20202020 20202020 20202020
  980. 000320  20202020 20202020 20202020 20202020
  981. 000330  20202020 20202020 20202020 20202020
  982. 000340  20202020 20202020 20202020 20202020
  983. 000350  20202020 20202020 20202020 20202020
  984. 000360  20202020 20202020 20202020 20202020
  985. 000370  20202020 20202020 20202020 20202020
  986. 000380  20202020 20202020 20202020 20202020
  987. 000390  20202020 20202020 20202020 20202020
  988. 0003A0  20202020 20202020 20202020 20202020
  989. 0003B0  20202020 20202020 20202020 20202020
  990. 0003C0  20202020 20202020 20202020 20202020
  991. 0003D0  20202020 20202020 20202020 20202020
  992. 0003E0  20202020 20202020 20202020 20202020
  993. 0003F0  20202020 20202020 20202020 334E3139              3N19
  994. 000400  39363031 30321A                      960102.
  995.  
  996. ---------------------------------------------------------------------------
  997.  
  998. Hex dump of test.ndx
  999.  
  1000. 000000  01000000 02000000 00000000 08001F00  ................
  1001. 000010  01001000 00000000 49442000 80028403  ........ID .....
  1002. 000020  31002B00 03000100 03000100 01000100  1.+.............
  1003. 000030  01000100 01000100 01000100 01000100  ................
  1004. 000040  01000100 01000100 01000100 01000100  ................
  1005. 000050  01000100 01000100 01000100 01000100  ................
  1006. 000060  01000100 01000100 01000100 01000100  ................
  1007. 000070  01000100 01000100 01000100 01000100  ................
  1008. 000080  01000100 01000100 01000100 01000100  ................
  1009. 000090  01000100 01000100 01000100 01000100  ................
  1010. 0000A0  01000100 01000100 01000100 01000100  ................
  1011. 0000B0  01000100 01000100 01000100 01000100  ................
  1012. 0000C0  01000100 01000100 01000100 01000100  ................
  1013. 0000D0  01000100 01000100 01000100 01000100  ................
  1014. 0000E0  01000100 01000100 01000100 01000100  ................
  1015. 0000F0  01000100 01D3EA03 DABA5800 03D03BDA  ..........X...;.
  1016. 000100  770CB8FE FFA20E69 5F5E8BE5 5DCB33DB  w......i_^..].3.
  1017. 000110  8EC3B452 CD218CC0 0BC37410 268E47FE  ...R.!....t.&.G.
  1018. 000120  26803E00 004D7504 8C060069 8E060269  &.>..Mu....i...i
  1019. 000130  8CC1268B 1E010026 8B160300 83EA58BE  ..&....&......X.
  1020. 000140  00008B3E 0669A100 69C70600 6900008E  ...>.i..i...i...
  1021. 000150  C03BC174 153BC774 1C263B1E 01007515  .;.t.;.t.&;...u.
  1022. 000160  4626A103 00050200 03D0833E 00690075  F&.........>.i.u
  1023. 000170  048C0600 6926803E 00004D75 0A8CC026  ....i&.>..Mu...&
  1024. 000180  03060300 40EBC889 56FE8936 0C69F746  ....@...V..6.i.F
  1025. 000190  06100075 6AF74606 0100745C 1EB067B4  ...uj.F...t\..g.
  1026. 0001A0  35CD218C C88ED8BE 15A5BF0A 00B90800  5.!.............
  1027. 0001B0  F3A61F75 43B440CD 670AE475 3BB446CD  ...uC.@.g..u;.F.
  1028. 0001C0  670AE475 33C86F7C 26D632D6 326A01A5  g..u3.o|&.2.2j..
  1029. 0001D0  3420007C 26E4326C 10881411 346431F0  4 .|&.2l....4d1.
  1030. 0001E0  32643104 00FA3340 07881415 34643133  2d1...3@....4d13
  1031. 0001F0  003000EB 3F494400 F7460610 00754BF7  .0..?ID..F...uK.
  1032. 000200  03000000 00000000 01000000 00000000  ................
  1033. 000210  0000F03F 00000000 02000000 00000000  ...?............
  1034. 000220  00000040 00000000 03000000 00000000  ...@............
  1035. 000230  00000840 00000000 5F03C102 5F035101  ...@...._..._.Q.
  1036. 000240  7B007C00 7D005101 6C036D03 57026E03  {.|.}.Q.l.m.W.n.
  1037. 000250  AE025702 54025101 A7025101 FB015900  ..W.T.Q...Q...Y.
  1038. 000260  31005101 0C025D03 5101C302 C402C502  1.Q...].Q.......
  1039. 000270  C602C702 C802C902 CA025101 C5010802  ..........Q.....
  1040. 000280  AE034201 9B000902 2F02DA00 0A02FD02  ..B...../.......
  1041. 000290  06000800 09000A00 0B000C00 0D000E00  ................
  1042. 0002A0  0F000700 AB00AD00 AE00AF00 B000B100  ................
  1043. 0002B0  B200B300 B400AC00 C5011F03 51014201  ............Q.B.
  1044. 0002C0  5101DD01 5101DA00 5101FD02 C5015101  Q...Q...Q.....Q.
  1045. 0002D0  51014201 51015101 51015101 5101FD02  Q.B.Q.Q.Q.Q.Q...
  1046. 0002E0  51015101 51015101 51015101 43035101  Q.Q.Q.Q.Q.Q.C.Q.
  1047. 0002F0  5101FD02 D2025F03 DC025F03 E0025F03  Q....._..._..._.
  1048. 000300  DB025F03 DF025F03 DD025F03 DE025F03  .._..._..._..._.
  1049. 000310  5702E102 57025402 51015602 E202D302  W...W.T.Q.V.....
  1050. 000320  5201D402 AE02AF02 B002B102 B202B302  R...............
  1051. 000330  52015402 51015E00 5F006000 61005101  R.T.Q.^._.`.a.Q.
  1052. 000340  5602D502 D3025201 D802D902 5201DA02  V.....R.....R...
  1053. 000350  AF02B002 52015702 54025101 CB02CC02  ....R.W.T.Q.....
  1054. 000360  CD02CE02 CF02D002 51015602 AD02AE02  ........Q.V.....
  1055. 000370  AF02B002 B102B202 54025702 51015602  ........T.W.Q.V.
  1056. 000380  D602D302 5201AE02 D7025402 57025101  ....R.....T.W.Q.
  1057. 000390  80023100 51018002 84033100 51018002  ..1.Q.....1.Q...
  1058. 0003A0  31005101 11015F03 51014800 49005101  1.Q..._.Q.H.I.Q.
  1059. 0003B0  A600C102 51014C03 31005101 4C038602  ....Q.L.1.Q.L...
  1060. 0003C0  31005101 56021B00 54021D00 56025201  1.Q.V...T...V.R.
  1061. 0003D0  5F031C00 51025602 AE02AF02 5802B002  _...Q.V.....X...
  1062. 0003E0  B1025002 52015702 54025101 50025402  ..P.R.W.T.Q.P.T.
  1063. 0003F0  1E001F00 51022000 5602B102 B302B502  ....Q. .V.......
  1064.  
  1065. ---------------------------------------------------------------------------
  1066.  
  1067. Hex dump of test.dbt
  1068.  
  1069.            *1       *2
  1070.         vvvvvvvv vvvvvvvv
  1071. 000000  04000000 8701021D 03000002 5E126431  ............^.d1
  1072. 000010  03000000 00000300 00008701 021D0300  ................   \
  1073. 000020  00025E12 64310300 00000000 02000000  ..^.d1..........    |
  1074. 000030  8701021D 03000002 5E126431 03000000  ........^.d1....    |
  1075. 000040  00000100 00006572 69632020 44617465  ......eric  Date    |
  1076. 000050  20202020 204C6F67 6963616C 20204D65       Logical  Me    |
  1077. 000060  6D6F2020 20202000 FF7604E8 26CF83C4  mo     ..v..&...    |
  1078. 000070  0C5E5FC9 C3908B76 048B4606 50568976  .^_....v..F.PV.v    |
  1079. 000080  EA8946EC 900EE855 9B83C404 C45EEA2A  ..F....U.....^.*    |
  1080. 000090  E4268A47 24C45E0A 268907C4 5EEA268A  .&.G$.^.&...^.&.    | Header
  1081. 0000A0  47048E46 10268905 C45EEA26 F6471610  G..F.&...^.&.G..    | (mostly
  1082. 0000B0  7503E9A3 00C45E0A 26832F02 5E5FC9C3  u.....^.&./.^_..    | garbage)
  1083. 0000C0  6A01EB9A 16261F11 1F110300 C1009219  j....&..........    |
  1084. 0000D0  00B8D80A BE197C26 16262411 24110300  ......|&.&$.$...    |
  1085. 0000E0  D500A619 00B8E20A D2197C26 BF186DD0  ..........|&..m.    |
  1086. 0000F0  0670A107 A1080672 CC026431 7C26BA19  .p.....r..d1|&..    |
  1087. 000100  DC01CC19 D2196431 2F001100 21002F00  ......d1/...!./.    |
  1088. 000110  6D00D21A 0318CC19 21000300 D2196431  m.......!.....d1    |
  1089. 000120  11002100 1E1B6431 03002020 20006163  ..!...d1..   .ac    |
  1090. 000130  74657200 5E5FC9C3 8B760023 2300268A  ter.^_...v.##.&.    |
  1091. 000140  44032AE4 8CC1C45E 0A268907 8EC1268A  D.*....^.&....&.    |
  1092. 000150  44028E46 10268905 5E5FC9C3 C8060000  D..F.&..^_......    |
  1093. 000160  57568B4E 108B7E14 32C0F406 F10A1200  WV.N..~.2.......    |
  1094. 000170  F10A4400 8E1A3C1A F6006C22 08000F00  ..D...<...l"....    |
  1095. 000180  07000002 0A00246F 0A02DE13 D0367C26  ......$o.....6|&    |
  1096. 000190  2E018221 06727C26 0814820A F10A0700  ...!.r|&........    |
  1097. 0001A0  0A00D036 00020A00 D0360000 00020700  ...6.....6......    |
  1098. 0001B0  00060000 0000D136 2C14E707 F10A0F00  .......6,.......    |
  1099. 0001C0  10001900 D036726D 7C260000 07000000  .....6rm|&......    |
  1100. 0001D0  00008C6D 08002A14 00007C26 9A018221  ...m..*...|&...!    |
  1101. 0001E0  46727C26 4614CB00 F10A0700 00000000  Fr|&F...........    |
  1102. 0001F0  00000700 0F060000 00008C6D 7C264E14  ...........m|&N.   /
  1103. 000200  54686973 20697320 61206D65 6D6F2066  This is a memo f   \ <-
  1104. 000210  6F726520 7265636F 7264206E 6F206F6E  ore record no on    |  | *3
  1105. 000220  651A1A11 C4D92E20 4C656176 65206D65  e...... Leave me    |<-
  1106. 000230  6E75202D 201B1A2E 20426C61 636B626F  nu - ... Blackbo    |
  1107. 000240  61726420 2D204631 302E0052 616E6765  ard - F10..Range    |
  1108. 000250  2076616C 7565206D 75737420 6265206E   value must be n    |
  1109. 000260  756D6572 69632E20 20507265 73732061  umeric.  Press a    |
  1110. 000270  6E79206B 65792074 6F20636F 6E74696E  ny key to contin    |
  1111. 000280  75652E00 2500EA08 00AA209A D0027F1D  ue..%..... .....    |
  1112. 000290  2400EA00 00911F9A D0027F1D 1100EA00  $...............    |
  1113. 0002A0  00451E9A D0027F1D 0800EA14 08D21D9A  .E..............    |
  1114. 0002B0  D0027F1D 1000EA00 00451E9A D0027F1D  .........E......    |
  1115. 0002C0  1900EA00 00D21D9A D0027F1D 0C00EA00  ................    |
  1116. 0002D0  00D21D9A D0027F1D 1800EA00 00D21D9A  ................    |
  1117. 0002E0  D0027F1D 0A00EA00 00D21D9A D0027F1D  ................    |
  1118. 0002F0  1300EA00 0068219A D0027F1D 1200EA00  .....h!.........    |
  1119. 000300  0068219A D0027F1D 1400EA00 0068219A  .h!..........h!.    |
  1120. 000310  D0027F1D 1600EA00 0068219A D0027F1D  .........h!.....    |
  1121. 000320  1600EA05 0368219A D0027F1D 1500EA00  .....h!.........    |
  1122. 000330  0068219A D0027F1D 1200EA24 0968219A  .h!........$.h!.    |
  1123. 000340  D0027F1D 1200EAC8 0E68219A D0027F1D  .........h!.....    |
  1124. 000350  1200EA82 1268219A D0027F1D 1200EABD  .....h!.........    |
  1125. 000360  0168219A D0027F1D 1200EAA8 1468219A  .h!..........h!.    |
  1126. 000370  D0027F1D 1200EA7D 0068219A D0027F1D  .......}.h!.....    |
  1127. 000380  1200EA3D 0068219A D0027F1D 1200EAB2  ...=.h!.........    |
  1128. 000390  0068219A D0027F1D 1200EA1A 0D68219A  .h!..........h!.    |
  1129. 0003A0  D0027F1D 1200EAE3 1268219A D0027F1D  .........h!.....    |
  1130. 0003B0  1200EA44 1368219A D0027F1D 2400EA35  ...D.h!.....$..5    |
  1131. 0003C0  09911F9A D0027F1D 2400EA4F 0B911F9A  ........$..O....    |
  1132. 0003D0  D0027F1D 2400EA56 1E911F9A D0027F1D  ....$..V........    |
  1133. 0003E0  2400EAC7 1E911F00 00000000 00000000  $...............    |
  1134. 0003F0  BE000026 8B8C0400 41742E26 8B940800  ...&....At.&....   _|
  1135. 000400  54686973 20697320 6D656D6F 20666F72  This is memo for   \ <- Second
  1136. 000410  20726563 6F726420 321A1A1C 00040000   record 2.......    |<- entry
  1137. 000420  E54F5445 30332020 4E445800 00000000  .OTE03  NDX.....    |
  1138. 000430  00000000 00002099 8C1F8945 00040000  ...... ....E....    |
  1139. 000440  E54F5445 30202020 44425400 00000000  .OTE0   DBT.....    |
  1140. 000450  00000000 00009C94 821F9345 00040000  ...........E....    |
  1141. 000460  E54F5445 30202020 44424600 00000000  .OTE0   DBF.....    | Second
  1142. 000470  00000000 00009C94 821F9445 28020000  ...........E(...    | block
  1143. 000480  E54F5445 30342020 4E445800 00000000  .OTE04  NDX.....    |
  1144. 000490  00000000 00002232 8D1F6E1C 00040000  ......"2..n.....    |
  1145. 0004A0  E5455820 20202020 20202000 00000000  .EX        .....    |
  1146. 0004B0  00000000 00004C32 8D1F8A45 FD2F0000  ......L2...E./..    |
  1147. 0004C0  E545447B 45442020 45444320 00000000  .ED{ED  EDC ....    |
  1148. 0004D0  00000000 00008532 8D1F0000 00000000  .......2........    |
  1149. 0004E0  E545447B 45443120 45445420 00000000  .ED{ED1 EDT ....    |
  1150. 0004F0  00000000 00008532 8D1F0000 00000000  .......2........    |
  1151. 000500  E545447B 45443120 45444220 00000000  .ED{ED1 EDB ....    |
  1152. 000510  00000000 00008532 8D1F0000 00000000  .......2........    |
  1153. 000520  E545447B 45442020 45445320 00000000  .ED{ED  EDS ....    |
  1154. 000530  00000000 00008532 8D1F8D45 00100000  .......2...E....    |
  1155. 000540  00000000 00000000 00000000 00000000  ................    |
  1156. 000550  00000000 00000000 00000000 00000000  ................    |
  1157. 000560  00000000 00000000 00000000 00000000  ................    |
  1158. 000570  00000000 00000000 00000000 00000000  ................    |
  1159. 000580  00000000 00000000 00000000 00000000  ................    |
  1160. 000590  00000000 00000000 00000000 00000000  ................    |
  1161. 0005A0  00000000 00000000 00000000 00000000  ................    |
  1162. 0005B0  00000000 00000000 00000000 00000000  ................    |
  1163. 0005C0  00000000 00000000 00000000 00000000  ................    |
  1164. 0005D0  00000000 00000000 00000000 00000000  ................    |
  1165. 0005E0  00000000 00000000 00000000 00000000  ................    |
  1166. 0005F0  00000000 00000000 00000000 00000000  ................   _|
  1167. 000600  54686973 20697320 6D656D6F 20331A1A  This is memo 3..   <- 3rd entry *4)
  1168.  
  1169. *1)
  1170.      First 4 bytes indicates no. of next free block
  1171. *2)
  1172.      (FoxBase) Size of blocks. This is a dBASE III+ file and byte 4-511 is
  1173.      just garbage.
  1174. *3)
  1175.      First entry (terminated by 1Ah 1Ah)
  1176. *4)
  1177.      NOTE! Last entry is NOT a complete block. dBASE does not write the
  1178.      full block to the memo file. The block contains the memo + terminator
  1179.      (1Ah 1Ah)
  1180.  
  1181. ---------------------------------------------------------------------------
  1182.  
  1183. dBASE Specifications
  1184.  
  1185.                                 dBASE II        dBASE III       dBASE IV
  1186. Max. no. of records                             1,000,000,000   1,000,000,000
  1187. Max. fields per record                          128             255
  1188. Max. data files open                            10              10
  1189. Max. index files per open database              7               47
  1190. Max. record size                                4,000 bytes     4000 bytes
  1191. Max. records per file                           65,535
  1192. Max. bytes per file                             8,000,000
  1193. Max. memory variables                           256
  1194. Max. memory for variables                       6,000 bytes *3
  1195. No. of data types                               5               6
  1196. Max. size of MEMO file                          5000 bytes      64000 bytes
  1197. Max. character field size                       254 bytes       254 bytes
  1198. Max. numerical field size                       19 bytes        20 bytes
  1199. Size of logical field                           1 byte          1 byte
  1200. Size of date field                              8 bytes         8 bytes
  1201. Size of memo pointer in DBF                     10 bytes
  1202. Size of floating point          -               -               1-2
  1203.  
  1204. *3       Can be expanded to 31 KB using CONFIG, 6 KB is mentioned as default.
  1205.  
  1206. ---------------------------------------------------------------------------
  1207.  
  1208. HISTORY
  1209.  
  1210. 1997-03-10
  1211.  
  1212.      Still more references and updates of references.
  1213.  
  1214. 1997-01-27
  1215.  
  1216.      Description of .MEM (Memory index file) and .NTX (Clipper Index File).
  1217.  
  1218.      Description of Database Container in Visual FoxPro
  1219.      More references and various minor changes in text.
  1220.  
  1221. 1997-01-09
  1222.  
  1223.      Description of .MDX (Multiple index file)
  1224.  
  1225. 1996-11-27
  1226.  
  1227.      Document converted to HTML
  1228.  
  1229. 1996-11-19
  1230.  
  1231.      Minor fixes:
  1232.  
  1233.      Elements in Field Descriptor Array are exact 32 B long.
  1234.      Typing error in data type Float.
  1235.  
  1236. "What to check on opening a .DBF file" added.
  1237.  
  1238. 1996-10-18
  1239.  
  1240.      Chapter on read/write locks using share by Phil Barnett
  1241.      (philb@iag.net)
  1242.  
  1243. 1996-10-15
  1244.  
  1245.      Change in description of structure of index files.
  1246.  
  1247.      Major mistake! The previous version described the structure for
  1248.      dBASE II index files.
  1249.      Only excuse: This mistake was made by several of my sources :-(
  1250.  
  1251. 1996-10-03
  1252.  
  1253.      First public version of this document (as far as I remember :-)
  1254.  
  1255. ---------------------------------------------------------------------------
  1256.  
  1257. REFERENCE LIST
  1258.  
  1259.   1. Bachmann, Erik:
  1260.  
  1261.      Xbase : File format description / Erik Bachmann. - Roskilde, Denmark :
  1262.      Clickety Click Software, 1996-1997. - aprox. 17 pg. ; ASCII text file
  1263.  
  1264.      URL: http://www.geocities.com/SiliconValley/Pines/2563/Xbase.html
  1265.      or
  1266.      URL: http://www.wotsit.demon.co.uk/formats/dbf/xbasefmt.txt (ASCII
  1267.      Text)
  1268.  
  1269.   2. CA-Clipper File Structures : Detailed Structure Information. . - (
  1270.      Xbase Techniques. ; Computer Associates International, Inc. ). - 1993.
  1271.      - Pg. 7-10
  1272.  
  1273.      Reference from: Ben Engbers
  1274.  
  1275.   3. Castro, L.:
  1276.  
  1277.      Advanced programmer's guide featuring dBASE III and dBASE II / L.
  1278.      Castro. - Culver City, California, USA : Ashton-Tate, 1985. - 10+664
  1279.      pg. - ISBN 0-912677-05-8
  1280.  
  1281.      Note: Literature list and Terminology list
  1282.  
  1283.   4. dBASE .DBF File Structure. - (Borland Technical Documents ; TI12821)
  1284.  
  1285.      URL: http://loki.borland.com/winbin/bds.exe?getdoc+2821+Delphi
  1286.  
  1287.   5. Eacker, Brad:
  1288.  
  1289.      DBF : A set of tools and library routines to manipulate xbase files /
  1290.      Brad Eacker : Silicon Graphics, 1994. - Computer files ; C source ;
  1291.      ASCII text
  1292.  
  1293.      Note: UUNET vol. 43 1994
  1294.  
  1295.      Abstract: UUnet : volume43 (Period: 08 Jun 94 - 24 Jul 94),
  1296.      dbf/part0[1-2] : dbf - xbase manipulation package
  1297.  
  1298.      URL: ftp://ftp.uu.net/usenet/comp.sources.misc/volumen43/dbf/part01
  1299.  
  1300.   6. Err : "Not a Database File". - (Microsoft Knowledge Base. ; Article
  1301.      Q98743)
  1302.  
  1303.      URL: http://www.microsoft.com/kb/developr/fox/q98742.htm
  1304.  
  1305.   7. Gmelch, Rasca:
  1306.  
  1307.      libdbf : simple routines for accessing xbase data files / Rasca
  1308.      Gmelch. - Berlin, 1996. - Computer files ; C source ; ASCII text
  1309.  
  1310.      URL: http://home.pages.de/~rasca/dbflib/
  1311.  
  1312.      or
  1313.  
  1314.      URL: http://www.komm.hdk-berlin.de/home/rasca/dbflib-0.6/index.html
  1315.  
  1316.   8. Hogan, T.:
  1317.  
  1318.      The Programmers's PC sourcebook : Reference tables for IBM PCs and
  1319.      compatibles, PS/2 systems, EISA-based systems, MS-DOS operating system
  1320.      through version 5, Microsoft Windows through version 3 : Hundred of
  1321.      new charts and tables / T. Hogan. - Redmond, Washington, USA :
  1322.      Microsoft Press, 1991. - Multiple pagination. - ISBN 1-55615-321-X
  1323.  
  1324.   9. How to Modify the Table Header from FoxPro. - (Microsoft Knowledge
  1325.      Base. ; Article Q139758 ; )
  1326.  
  1327.      URL: http://www.microsoft.com/kb/developr/fox/q139758.htm
  1328.  
  1329.  10. Pereira, Pratap
  1330.  
  1331.      Xbase.pm v. 1.07 : a module for perl 5
  1332.  
  1333.      Author Source:
  1334.      http://eewww.eng.ohio-state.edu/~pereira/software/xbase/
  1335.  
  1336.      Author Address: pereira@ee.eng.ohio-state.edu
  1337.  
  1338.  11. Simpson, Alan:
  1339.  
  1340.      dBASE III PLUS : Programmer's Reference Guide / Alan Simpson. - Almeda
  1341.      : Sybex Inc., 1987. - 1029 pg. - ISBN 0-89588-301-5
  1342.  
  1343.      Abstract: Data file structure and memo file structure for xBase
  1344.  
  1345.  12. Spence, Rick:
  1346.  
  1347.      Clipper Programming Guide / Rick Spence. - 2.nd edition. - Microtrend
  1348.      Books, Slawson Communications, Inc. - ISBN 0-915391-41-4
  1349.  
  1350.  13. Stevens, A.:
  1351.  
  1352.      Turbo C : Memory-resistent utilities, screen I/O and programming
  1353.      techniques / A. Stevens. - Portland, Origon, USA : MIS Press, 1987. -
  1354.      10+315 pg. - ISBN 0-943518-35-0
  1355.  
  1356.      Note: Video Windows and TSR utility programs
  1357.  
  1358.  14. Townsend, Carl:
  1359.  
  1360.      Mastering dBASE III : A Structured Approach / Carl Townsend. -
  1361.      Berkeley : Sybex Inc., 1985. - ISBN 0-89588-301-5
  1362.  
  1363.      Abstract: Data file structure and index file structure for xBase
  1364.  
  1365.  15. Walden, J.:
  1366.  
  1367.      File formats for popular PC software : A programmer's reference / J.
  1368.      Walden. - New York, New York, USA : Wiley, 1986. - 16+287 pg. - ISBN
  1369.      0-471-83671-0
  1370.  
  1371.  16. WANG, Thomas:
  1372.  
  1373.      Transactional Locking, Part 1 / Thomas Wang (wang@cup.hp.com)
  1374.  
  1375.      URL: http://www.concentric.net/~Ttwang/tech/locks1.htm
  1376.  
  1377.  17. What FoxPro Checks When Opening a .DBF File. - (Microsoft Knowledge
  1378.      Base. ; Article Q119763)
  1379.  
  1380.           URL: http://www.microsoft.com/kb/developr/fox/q119763.htm
  1381.  
  1382. ---------------------------------------------------------------------------
  1383.  
  1384.                                 END OF FILE
  1385.  
  1386. ---------------------------------------------------------------------------
  1387.