Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Advantage CA-Clipper Guide v6.11 - reindex http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 REINDEX
 Rebuild open indexes in the current work area
------------------------------------------------------------------------------

 Syntax

     REINDEX [EVAL <lCondition> [EVERY <nRecs>]]

     EVAL <lCondition> is an expression (usually a UDF) that is evaluated
     for each record indexed. This allows the program to display some type
     of completion/process meter without having the UDF embedded in the
     index expression. Indexing stops if the EVAL condition returns a (.F.).

     The evaluations take place at record 1, 2, etc. or the set EVERY
     parameter (see below). The record number can be tested within your
     UDF using RecNo().

     The EVAL clause commonly contains UDFs to display the status of index
     creation. The UDF is stored on the client while the index building
     occurs on the server. If the EVAL condition is specified, the clause
     is evaluated every 2 seconds on the client. Advantage updates the
     internal record number and the number of keys included so far. If the
     functions RecNo() and/or AX_KeysIncluded() are used, the correct
     results are returned.

     Note  When using EVAL, CA-Clipper indicates the percentage based
     on how many records have been extracted from the table to
     sort. CA-Clipper extracts a block of records, sorts it, and repeats
     this process until all records in the table have been extracted. Once
     the blocks are sorted, the index is built. Thus, the extraction/
     sorting of records is more significant than the build time. Advantage,
     on the other hand, has shorter record extraction times relative to
     the build. It is possible that when the EVAL clause returns a FALSE
     to abort an index build, it may take longer to abort the index build
     than expected. If the extraction is done, the build continues.
     Otherwise, if a FALSE is returned during key extraction, an empty
     index is created.

     EVERY <nRecs> is used to specify how often the EVAL expression will
     be evaluated. <nRecs> is a numeric value representing the number of
     records to be processed before the EVAL expression is evaluated. If
     this is specified and if the index is built on the server, Advantage
     ignores the record count. Instead, the status of the EVAL is returned
     every 2 seconds.

 Description

     REINDEX rebuilds all open indexes in the current work area.  When the
     reindexing operation finishes, all rebuilt indexes remain open, order
     is not changed, and the record pointer is positioned on the first
     record in the controlling index.  REINDEX obeys any previous FOR,
     UNIQUE, or DESCENDING clauses.  REINDEX requires exclusive use of the
     current table.

     Note:  CA-Clipper's documentation for REINDEX states that the order
     will be reset to one.  However, CA-Clipper's implementation leaves
     the order as is.  We match CA-Clipper's implementation, not their
     documentation.

     Note: REINDEX is illegal if performed within a transaction.
     If REINDEX is called while within a transaction, a runtime error
     will occur.

 Example

     In this example, ShowIt() will be called every 10 records.  The
     default step value is 1.

     #include "DBFCDXAX.CH"

     USE test VIA "DBFCDXAX"             // TEST.CDX opened automatically
     REINDEX EVAL ShowIt() EVERY 10

     FUNC ShowIt()

        // Display the appropriate message
        ? IF( AX_IsReindex(), "Reindexing ", "Indexing" )

        // Display the index file and tag name
        ? AX_I_IndexName() + " : " + AX_I_TagName()
        ?

        // Show how many keys have been included
        @ ROW(), 1 SAY AX_KeysIncluded()

     RETURN ( .T. )


See Also: INDEX AX_IsReindex() AX_I_IndexName() AX_I_TagName()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson