FILE: Use CDX(),TAG(), and SYS(14) Function to Create an Index Utility (202520)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Macintosh 3.0b

This article was previously published under Q202520

SUMMARY

GenTags.exe is a sample file that contains a FoxPro program which creates another FoxPro program that you can then run to rebuild index files for FoxPro tables.

MORE INFORMATION

The following files are available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. Power failures, system crashes, network issues, and user actions occasionally result in corrupted indexes. Corrupt indexes, in turn, are a frequent cause of General Protection Faults and Invalid Page Faults. Issuing a REINDEX command does not resolve the issues associated with a corrupt index. Consequently, a plan for regular index maintenance, involving deletion and re-creation of index tags, is an essential aspect of application design and development.

Under FoxPro 2.6, index corruption issues are relatively easily resolved by deleting and re-creating the IDX/CDX files. Visual FoxPro brought the addition of Primary Keys, Candidate Keys, Foreign Keys, and Persistent Relationships. The addition of those features and more robust Referential Integrity functions has made the process of maintaining indexes considerably more complicated.

With Visual FoxPro, one option for re-creating corrupt indexes is to use GenDBC.prg to re-create the database structure and indexes, and then restore the data back to each table. Another option is to use the sample file GenTags.prg to create a program file to perform index maintenance tasks.

To use the GenTags.prg file:
  1. Place the GenTags.prg file in the same directory as the tables that have index files that you want to rebuild.
  2. Run the program by typing the following in the Command window:
    DO GenTags.prg 
    						
    This creates a program named Rebld.prg.
  3. To re-create the index files for the tables, type the following in the Command window:
    DO Rebld.prg
    						
    You can use the Rebld.prg file again whenever the indexes for the tables need to be rebuilt. Be sure to run GenTags.prg again to re-create the Rebld.prg if the indexes are modified.
WARNING: Running the code generated by GenTags.prg with a Visual FoxPro database containing Referential Integrity (RI) code generated by the RI Builder, results in loss of those RI functions.

Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbDatabase kbhowto kbXBase KB202520