
                    FoxBase/Pro .IDX File Structures

We have determined the IDX file structure to be as follows.

Note that this information is NOT from Fox Software, and may not be
completely accurate in every respect (SEE NOTES, NEXT PAGE). However, we have
used it as the basis of our enhancements to Code Base 4.x and it appears to
work properly in accessing and updating .IDX files.

/* HEADER (block at file offset 0 - 512 bytes) */
long root;          /* pointer to root index block */
long what1;         /* don't know - always has FFFF in file, but temporarily
                       seems to hold pointer to last block */
long next;          /* next available index block */
short key_len;      /* length of key data */
short what2;        /* don't know - seems to always be nulls? */
char key_expr[220]  /* index key expression */
char for_expr[220]  /* conditional expression */


  /* For Code Base, you must calculate data that is contained
     in .NDX/.NTX, but not in .IDX: */
  short group_len;    /* = key_len + 4, length of index_data item pairs */
  short max_keys;     /* = integer(500/group_len) */



/* INDEX (block of 512 bytes containing index data */
short block_type;  /* 0  : branch blocks, point to other branch/leaf blocks;
                      1  : root block, points to branch/leaf blocks;
                      2  : leaf blocks point to dbrecs;
                      3  : "only" leaf (seedling) block            */
short num_keys;    /* number of keys in block */
long bak_blk;      /* pointer to "previous" block */
long fwd_blk;      /* pointer to "next" block */
unsigned char index_data[500] /* contents of this block are basically a
                                    set of <num-keys> pairs of index data
                                    in the form:
                                    (1) <key-type> key; (length key_len bytes)
                                    (2) long key_ptr; */

/* NOTE: for block_type =0,1: key_ptr is INDEX block reference,
                         2,3: key_ptr is dbf rec number */


----------------------------------------------------------------------------
                                    NOTES
----------------------------------------------------------------------------


1. For additional (or perhaps better) information, you might check the
   following references, as obtained from posted CIS messages:

     Pete Olympia and Kathy Cea's book, Developing FoxPro Applications
     Programmer's Journal 8.6 (November/December 1990).

2. Per request of Howard Moskowitz of Fox Software (7/9/91) , we have moved
   the following paragraph from the top of this documentation file to the
   bottom. Actually, Howard asked us to remove it entirely, characterizing it
   as "more of a message than documentation," but after due consideration, we
   decided that it is an integral part of the derivation of the documentation
   given above, and are therefore leaving it in. Howard also said that Fox
   Software is now sending out the file structure without requiring a NDA,
   and "sends about six copies a day," so you may want to ask the SYSOPs for
   the procedure to forward a request for this info.

       "Note that we were unable to obtain any assistance from Fox - we
       tried repeatedly during the Winter of 90-91 and Spring of 91, and
       the few responses we got from them said "oh, noooo, this is
       proprietary information - you'll have to sign a NDA, send a fax
       to <XXX>" - then, when we did so, they NEVER answered our FAXes,
       even to acknowledge transmission. BTW, we did point out to them
       that it was somewhat absurd to suggest the references [as shown
       above] and then claim "proprietary information" with the next
       breath - <BIG g>"

3. Also, per request of Howard Moskowitz, we reiterate that nothing in this
   entire docuumentation file is official Fox Software information, and that
   it is provided for your use at your own risk, and that Fox Software has
   neither responsibility, liability, nor credit for it.


For more information, contact:

SCR Corporation
309 East Holland Avenue / PO Box 1408
Alpine, Texas 79830

915/837-7180 (VOICE)
       -3482 (VOICE/DATA)
       -3509 (FAX)


<Last Update: 7/9/91>

