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

ID: Q202520


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a, 6.0
  • Microsoft Visual FoxPro for Macintosh, version 3.0b


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. Click the file names below to download the files:

GenTags.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center. 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.

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by John Desch, Microsoft Corporation

Additional query words:

Keywords : kbDatabase kbMAC kbUNIX kbVFp kbVFp300b kbVFp500 kbVFp500a kbVFp600 kbXBase KbDBFDBC kbGrpFox kbDSupport
Version : MACINTOSH:3.0b; WINDOWS:3.0,3.0b,5.0,5.0a,6.0
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


Last Reviewed: November 30, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.