Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- SIx Driver RDD v3.00 - Reference Guide - <b>sx_keycount():</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Sx_KeyCount():

  Syntax:  Sx_KeyCount( [nOrder] | [cTagName [, cIndexName ]] [, lLockIndex] )

           nOrder     = Position of tag in list of tag orders.
           cTagName   = Name of tag.
           cIndexName = Name of index file which contains cTagName.
           lLockIndex = Logical value indicating index locking mode to be
                        used.  The default is .T. (no index locking).

  Returns:   <numeric> 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 SCOPE and will
                  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 Mach SIx.

    NOTE:  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 database for deletion, the index KEY for those
           records will STILL be in the index, and will STILL be counted.
           If you do not want Sx_KeyNo() or Sx_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 is NOT supported under SIXNTX.

  Example:

    #include "SIXCDX.CH"

    // Create a standard Roll-Your-Own (RYO) Index

    USE test VIA "SIXCDX"               // Open database
    INDEX ON last TO last EMPTY         // Create EMPTY index file
    GOTO 10                             // Select a record
    Sx_KeyAdd()                         // Add a key for this record
    ? Sx_KeyData()                      // Displays key value for this rec
    ? Sx_KeyCount()                     // 1
    Sx_KeyDrop()                        // Delete this key from the index
    ? Sx_KeyCount()                     // 0

    // Create a Multi-Keyed, Free-Format RYO Index

    INDEX ON sxChar(12) TO phones       // Create empty index file
    GOTO 100                            // Select a record
    ? Sx_KeyCount()                     // 0
    Sx_KeyAdd( 0,0,"213-555-1212" )     // Add one phone number for this rec
    Sx_KeyAdd( 0,0,"213-555-9999" )     // Add another to the same record
    Sx_KeyAdd( 0,0,"310-222-9876" )     // And yet another phone number!
    ? Sx_KeyCount()                     // 3

    // Now delete all phone numbers (keys) for this record
    IF Sx_FindRec( 100, .F. )           // Find first key for this record
      ? "Deleting: " + Sx_KeyData()     // Display key value being deleted
      Sx_KeyDrop()                      // Delete first phone number
      DO WHILE Sx_FindRec( 100, .T. )   // Find any other keys for this rec
        ? "Deleting: " + Sx_KeyData()   // Display key value being deleted
        Sx_KeyDrop()                    // Delete other phone numbers
      ENDDO
    ENDIF
    ? Sx_KeyCount()                     // 0



See Also: Sx_KeyNo() hs_KeyCount() Sx_KeyAdd() Sx_KeyDrop() Sx_KeyData() Sx_IndexCount()

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