[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ATNUM()
 Determines the starting position of a sequence within a string
------------------------------------------------------------------------------
 Syntax

     ATNUM(<cSearchFor>,<cString>,[<nCounter>],
        [<nIgnore>]) --> nPosition

 Arguments

     <cSearchFor>  Designates the expression for which the function
     searches.

     <cString>  Designates the character string to search.

     <nCounter>  Designates which occurrence of <cSearchFor> within
     <cString> is determined.  The default value is for the last occurrence
     of the search expression.

     <nIgnore>  Designates the number of characters that should be
     excluded from the search.  The default value is none (0).

 Returns

     The function returns the position where <cSearchFor> begins.  If no
     corresponding position can be determined, the function returns 0.

 Description

     ATNUM() determines the initial position of the nth (<nCounter>)
     occurrence of <cSearchFor> within the <cString>.  Additionally, the
     function takes into account the CSETATMUPA() setting, which causes
     differing results.

     ATNUM() searches from the left in order to determine the nth
     (<nCounter>) occurrence of the <cSearchFor>.  If CSETATMUPA() is off,
     the search continues after the last character of the sequence most
     recently located.  However, if the CSETATMUPA() is on, the search always
     continues after the first character in the most recently located
     sequence.

     If the <nIgnore> parameter is not specified, the function initiates the
     search with the first character of <cString>.  If the <nIgnore>
     parameter is specified, <nIgnore> characters are ignored from the start
     of the string and are excluded from the search.

 Notes

     .  If no value is specified for <nCounter>, the function
        determines the last occurrence of the <cSearchFor> sequence.

     .  When you implement SETATLIKE(), wildcard characters can be
        used within the search expression.

 Examples

     .  Search for the last occurrence:

        ? ATNUM("bc", "abcdeabc")               // Result: 7

     .  Search for the first occurrence:

        ? ATNUM("bc", "abcdeabc", 1)            // Result: 2

     .  Search for the first occurrence, excluding the first three
        characters:

        ? ATNUM("bc", "abcdeabc", 1, 3)         // Result: 7

     .  Determine the impact of CSETATMUPA() on a search for the last
        occurrence of "aa" in "aaa":

        CSETATMUPA(.F.)                         // Off
        ? ATNUM("aa", "aaa")                    // Result: 1

        CSETATMUPA(.T.)                         // On
        ? ATNUM("aa", "aaa")                    // Result: 2


See Also: CSETATMUPA() SETATLIKE()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson