Hi,
You have to use pack to remove deleted records.
A VFP index is a subset of a main table that is placed in a sorted order. This allows VFP to find records in sub-second times, even in vary large tables. I'm not sure this is the way VFP uses an index, but a database could use a divide and conquer method to find records. This could be done as follows:
A database select the middle record in an index and evaluates whether the index row is above or below the selection criterion. If the selection criterion is below the index record selected, the database knows the expression would have to be in the bottom half of the index. Next the database divides the lower half of the index in half by selecting the middle record of the lower 1/2 of the index table. If the selection criterion is below this record, the database know the record is in the lower 1/4 of the index table. The database would continue in this manner until it found the index expression that matched the selection criterion. Then the database would grab the record number part of the index row that points to the corresponding record in the main table. Compare the divide and conquer index method, which could find the requested record by evaluating 8 to 15 rows in a table, to searching a 600 Meg table with a couple of million rows from top to bottom to find each record that met a criterion.
Each row in the index table contain the index fields selected along with the record number of the whole row in the main table. Therefore, once VFP finds the expression in the index, it can grab the record number in the main row to immediately retrieve it.
When a pack is performed, the record number of all rows change when a deleted record is removed from the table. For example, if one record is remove from a table, the record number of each row after the removed deleted record would shift by -1. This require a corresponding change to the index, so the index record number tagged onto the end of the sort expression point to the correct record in the main table. Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox