Return the position of a substring within a character string

     AT(<cSearch>, <cTarget>) --> nPosition


     <cSearch> is the character substring to be searched for.

     <cTarget> is the character string to be searched.


     AT() returns the position of the first instance of <cSearch> within
     <cTarget> as an integer numeric value.  If <cSearch> is not found, AT()
     returns zero.


     AT() is a character function used to determine the position of the first
     occurrence of a character substring within another string.  If you only
     need to know whether a substring exists within another string, use the $
     operator.  To find the last instance of a substring within a string, use


     .  These examples show typical use of AT():

        ? AT("a", "abcde")                  // Result: 1
        ? AT("bcd", "abcde")                // Result: 2
        ? AT("a", "bcde")                   // Result: 0

     .  This example splits a character string based on the position
        of a comma within the target string:

        cTarget := "Langtree, Lilly"
        ? SUBSTR(cTarget, 1, AT(",", cTarget) - 1)
        // Result: Langtree

        ? SUBSTR(cTarget, AT(",", cTarget) + 2)
        // Result: Lilly

 Files   Library is CLIPPER.LIB.



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.