Determines the starting position of a sequence within a string


        [<nIgnore>]) --> nPosition


     <cSearchFor>  Designates the expression for which the function

     <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).


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


     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

     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.


     .  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.


     .  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

        ? 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



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.