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 - ax_keycount() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 AX_KeyCount()
 Get number of keys in an index or tag
------------------------------------------------------------------------------

 Syntax

     AX_KeyCount( [<cOrder>|<nPosition>], [<cCDXName>] ) -> numeric

     <cOrder>  is a literal filename or character string specifying
     the name of the order. Using the order name is the preferred
     method since the position may be difficult to determine using
     multiple-order index files. If omitted or NIL, the controlling
     order is assumed.

     <nPosition> Assumed to be the number representing the position
     of an order in the active index file or specified index file (in
     <cCDXName>). If not a valid order position within the active or
     selected index file, then is assumed to be an index file order. If
     omitted or NIL, the controlling order is assumed.

     <cCDXName>  is a literal filename or character string
     specifying the name of an index file, including an optional
     drive and directory (no extension should be specified). Use
     this argument with <cOrder> to remove ambiguity when there are
     two or more orders with the same name in different index files.

 Returns

     Returns a numeric value indicating the number of index keys in the
     current or specified index file or tag.

 Description

     This function counts the number of keys in the current or specified
     index or tag and returns that value. If the current or specified
     index is a compound index then the currently active tag is used.

     This function respects any active index SCOPEs and will return the
     number of keys within the scope condition. It return the number of
     keys within the scope condition. It does not, however, respect a
     FILTER condition. In that scenario, it's best to use a COUNT command
     with Advantage Optimized Filters.

     Keep in mind that this function determines its return value strictly
     based on KEYS in the index file. If you have marked records in your
     table for deletion, the index KEY for those records will STILL be
     in the index, and will STILL be counted. If you do not want AX_KeyNo()
     or AX_KeyCount() to count keys for records marked as deleted, you
     must create the index as a CONDITIONAL index FOR !DELETED().
     For example:   INDEX ON last TAG last FOR !Deleted()

     Note:  This function will literally count every key in an index.
     So, if you are using extremely large indexes, this function may
     take a few seconds to complete.  Use of this function may also lead to
     poor multi-user performance as the index remains locked throughout the
     entire operation, which means other users cannot write to or read from
     that index until the Key Count operation is complete.

     Note: This function does not work with non-compact IDX indexes.

 Example

     // Assuming that TEST.PRG has 1000 records
     USE test VIA "DBFCDXAX"        // Open TEST.DBF

     INDEX ON last TAG last         // Create LAST tag
     GO TOP                         // Go to the top of the index
     ? RecNo()                      // Display record number (who knows?)
     ? AX_KeyNo()                   // Display key number (different from
                                    //   RecNo)
     GO BOTTOM                      // Go to the top of the index
     ? RecNo()                      // Display record number (who knows?)
     ? AX_KeyNo()                   // Display key number (different from
                                    //   RecNo)


See Also: AX_KeyNo()

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