157
4.20.2 DBF FILES AND IDX FILES
This one is an index sequential file structure. Table look-up and report generation is
easily supported by using index sequential file routines. There are actually two types of
files associated with this file structure, namely, DBF files and IDX files.
 A DBF file has a fixed record length structure. This is the file that stores data records
(members). Whereas, the associate IDX files are the files that keep information of the
position of each record stored in the DBF files, but they are re-arranged (sorted)
according to some specific key values.
 In addition to the IDX files that are explicitly created by user, the BASIC run-time
maintains a default IDX file which keeps the original data sequence.
A library would be a good example to illustrate how DBF and IDX files work. When you
are trying to find a specific book in a library, you always start from the index. The book
can be found by looking into the index categories of book title, writer, publisher, ISBN
number, etc. All these index entries are sorted in ascending order for easy lookup
according to some specific information of books (book title, writer, publisher, ISBN
number, etc.) When the book is found in the index, it will tell you where the book is
actually stored.
As you can see, the books kept in the library are analogous to the data records stored in
the DBF file, and, the various index entries are just its associate IDX files. Some
information (book title, writer, publisher, ISBN number, etc.) in the data records is used
to create the IDX files.
The length of each record in the DBF file is limited to 250 bytes. For mobile computers, a
BASIC program can have up to 5 DBF files. Each DBF file can have maximum 3
associated IDX files, and each of them is identified by its key (index) number.
Note: The valid key number ranges from 1 to 3.
Data records are not fetched directly from the DBF file but rather through its associated
IDX files.
The value of file pointers of the IDX files (index pointers) does not represent the address
of the data records stored in the DBF file. It indicates the sequence number of a specific
data record in the IDX file.