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 v5.5 - ax_seeklast() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 AX_SeekLast()
 Seeks to the last occurrence of a key
------------------------------------------------------------------------------

 Syntax

     AX_SeekLast( <xKey> [, <lSoftSeek>] ) -> logical

     <xKey>  The key in the currently active order to search for.

     <lSoftSeek>  A Logical value indicating if a soft seek is to be
     performed. This determines how you are positioned if the specified
     key is not found. If .T. is passed, and the key is not found, the
     record pointer will be positioned on the key with the next greater
     value. If .F. is passed, and the key is not found, the record
     pointer is positioned to lastrec() + 1 and the eof() flag is set.
     If no value is passed, a hard seek (not soft seek) is performed.

 Returns

     Returns a logical .T. if the specified key was found in the index,
     otherwise, .F. is returned.

 Description

     AX_SeekLast() is similar to CA-Clipper's dbSeek(), except that it
     finds the last occurrence of the specified key instead of the
     first.

     Using this function is substantially faster than SEEK'ing to the
     first occurrence and then SKIP'ing WHILE to the end of the
     matching keys.

     AX_SeekLast() properly handles the DESCENDING flag of the index.

 Example

     USE test VIA "DBFNTXAX"
     INDEX ON LAST + STR( AGE, 2 ) TO AGE

     // Find first Smith key in the index
     IF dbSeek( "Smith" )
        ? "The youngest Smith is " + RTrim( FIRST ) + " " + RTrim( LAST )
        ?? " at " + AllTrim( Str( AGE )) + " years old."

        // Find last Smith key in the index
        AX_SeekLast( "Smith" )
        ? "The oldest Smith is " + RTrim( FIRST ) + " " + RTrim( LAST )
        ?? " at " + AllTrim( Str( AGE )) + " years old."

     ELSE
        ? "No Smith found!"
     ENDIF


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