DATAFLEX 2.3B DATAFILE HEADER STRUCTURE

By Peter M. Grillo
MAINSTREAM COMPUTER CONSULTING


Following  is  the  structure of the  DataFlex  .DAT  file for 2.3. Data
Access  Corporation  has  deemed  the  structure  of  the  .DAT  file as
proprietary.  The  following definition of a  2.3  .DAT file was derived
independently  by  myself and any problem  arising  from the use of this
information will be your problem. Please do not call DAC and snivel. Use
at own risk. Please do not upload this to DAC's BBS.

DAC  has indicated to me that I can release this information providing I
include the prior disclaimer.

All  that  aside, this is everything I  know about a DataFlex .DAT file.
The overall layout of a 2.3 .DAT file is header, null record and data.

The  header  contains information about  the file definition. Just about
everything  you  define in DFFILE can be  found in the header except for
tag  names. It is possible to read the header of a 2.3 .DAT file and the
corresponding .TAG file to produce a perfect .DEF file.

The following show offsets into the header:
(LSB = Least significant byte)
(MSBT = Most significant bit)

DECIMAL         HEX      DESCRIPTION

01 - 04         00 - 03  HIGHEST RECORD COUNT EVER (LSB FIRST)

09 - 12         08 - 0B  RECORD COUNT (LSB FIRST)
13 - 16         0C - 0F  MAXIMUM NUMBER OF RECORDS (LSB FIRST)

79 - 80         4E - 4F  RECORD LENGTH (LSB FIRST)

89              58       DELETED SPACE (1=REUSED, 0=NOT REUSED)
90              59       NUMBER OF FIELDS

93              5C       MULTIUSER REREAD (1=ACTIVE, 0=INACTIVE)

101             64       NUMBER OF FIELDS IN INDEX 1 (MSBT SET 1 IF BATCH)
102-108         65 - 6B  FIELD SEGMENTS OF INDEX 1
109             6C       NUMBER OF FIELDS IN INDEX 2 (MSBT SET 1 IF BATCH)
110-116         6D - 73  FIELD SEGMENTS OF INDEX 2
117             74       NUMBER OF FIELDS IN INDEX 3 (MSBT SET 1 IF BATCH)
118-124         75 - 7B  FIELD SEGMENTS OF INDEX 3
125             7C       NUMBER OF FIELDS IN INDEX 4 (MSBT SET 1 IF BATCH)
126-132         7D - 83  FIELD SEGMENTS OF INDEX 4
133             84       NUMBER OF FIELDS IN INDEX 5 (MSBT SET 1 IF BATCH)
134-140         85 - 8B  FIELD SEGMENTS OF INDEX 5
141             8C       NUMBER OF FIELDS IN INDEX 6 (MSBT SET 1 IF BATCH)
142-148         8D - 93  FIELD SEGMENTS OF INDEX 6
149             94       NUMBER OF FIELDS IN INDEX 7 (MSBT SET 1 IF BATCH)
150-156         95 - 9B  FIELD SEGMENTS OF INDEX 7
157             9C       NUMBER OF FIELDS IN INDEX 8 (MSBT SET 1 IF BATCH)
158-162         9D - A3  FIELD SEGMENTS OF INDEX 8
163             A4       NUMBER OF FIELDS IN INDEX 9 (MSBT SET 1 IF BATCH)
164-170         A5 - AB  FIELD SEGMENTS OF INDEX 9
171             AC       NUMBER OF FIELDS IN INDEX 10 (MSBT SET 1 IF BATCH)
172-108         AD - B3  FIELD SEGMENTS OF INDEX 10

181 -183        B4 - BC  FILE ROOT NAME (NULL TERMINATED)


START OF FIELD DEFINITIONS.
REPEAT FOR EACH FIELD.

197-198         C4 - C5  FIELD OFFSET (LSB FIRST)
199             C6       MSBT=MAIN INDEX, LSBT=(DECIMAL POINTS/2)
200             C7       FIELD LENGTH
201             C8       FIELD TYPE 00=ASCII, 01=NUMERIC, 02=DATE, 03=OVERLAP
202             C9       RELATES TO FILE NUMBER
203-204         CA - CB  RELATES TO FIELD NUMBER (LSB FIRST)
...-...         .. - ..  (REPEAT FOR EACH FIELD)


The  null  record  follows the header  and  usually  contains 00h's. The
number  of bytes in the null record  corresponds to the record length of
the file. The null record is record number zero.

The  data that follows are records in order of record number. The number
of  bytes  in each record corresponds  to the record length. Records are
grouped  together  by  blocks  of 512  bytes.  Not  every record length,
however, divides evenly into 512 so you get the occurrence of fill bytes
or  0FFh's  to round out a group  of  records to 512 bytes. Consider the
following:

Record Length                   Layout
128                             Divides into 512 evenly so no fill
                                bytes are used

170                             Divided by 512 is 3 with a remainder
                                of 2 so after every 3 records
                                (starting at record 0) the are 2 fill
                                bytes (0FFh's)

Here is a table of common record lengths:

Record Length   Records in 512 Group    Number of Fill Bytes

256                     2                       0
170                     3                       2
128                     4                       0
102                     5                       2
85                      6                       2
73                      7                       1
64                      8                       0
56                      9                       8
51                      10                      2
46                      11                      6
42                      12                      8
39                      13                      5
36                      14                      8
34                      15                      2
32                      16                      0
30                      17                      2
28                      18                      8
26                      19                      18
25                      20                      12
24                      21                      8
23                      22                      6
22                      23                      6
21                      24                      8
20                      25                      12
19                      26                      18
18                      28                      8
17                      30                      2
16                      32                      0
15                      34                      2
14                      36                      8
13                      39                      5
12                      42                      8
11                      46                      6
10                      51                      2
9                       56                      8
8                       64                      0

> [fold]  [
> [fold]  [
Deleted records are filled with 00h's until reused.

DataFlex  .DAT  files can be opened  from .FLX files using DIRECT_INPUT.
You can then use READ_BLOCK commands to read information.

Reading  the  FILELIST.CFG  file  is  also  much  more  efficient  using
DIRECT_INPUT  and  READ_BLOCK.  The first 128  bytes  are  fill and each
successive  block of 128 bytes is a file in the list. In other words, if
you  want  file 15 then  DIRECT_INPUT  'FILELIST.CFG' and READ_BLOCK off
(15*128)  bytes.  This  would point you to  the  block for file 15. From
there  you  can read off bytes to  find  the Root Name, Description, and
DataFlex Name using the following layout.

> [fold]  ]
> [fold]  ]
DECIMAL         HEX      DESCRIPTION

01 - 41         00 - 28  FILE ROOT NAME (NULL TERMINATED)
42 - 74         29 - 49  FILE DESCRIPTION (NULL TERMINATED)
75 - 128        4A - 7F  DATAFLEX FILE NAME (NULL TERMINATED)

> [fold]  2
