Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Clipper Tools One Guide - <b>atrepl()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ATREPL()

Syntax:     ATREPL(<expC1>,[@]<expC2>,<expC3>[,<expN>][,<expL>])

Arguments:  <expC1> is the string to search for in <expC2>.
            <expC2> denotes the string in which to search for <expC1>.
            <expC3> contains the string to replace <expC2> with.
            <expN> denotes the number of the occurrence of <expC1>
            in <expC2> to be replaced by <expC3>.
            <expL> denotes whether only the sequence found (.T.) or all
            sequences up to the one found (.F.) are required to be
            replaced.

Returns:    A character string.
            The function will return a string in which one or all <expC1>
            strings are to be replaced by <expC3>.

Usage:      This function can be  used to replace one or several
            occurrences of <expC1> within the <expC2> string.  The
            <expN> argument determines which occurrence of <expC1>
            is to be sought.  The last occurrence is assumed if no value
            is specified.  All <expC1> up to and including the one sought
            will be replaced unless a value greater than 0 is specified for
            <expN> and (.T.) for <expL>.  The function checks the
            setting of CSETATMUPA(), hence ATREPL() will return
            different results accordingly.  If CSETATMUPA() is switched
            off (.F.) then the search will continue from the next character
            after each occurrence of the <expC1> string.  IF
            CSETATMUPA() is switched on (.T.) then the search will be
            continued from the current replacement.

Notes:      The length of <expC3> may be smaller, but under no
            circumstances greater than the string sought.  No
            replacement will take place if <expC3> is specified as greater
            than <expC1>.  The <expC2> argument may be passed by
            reference but <expC1> and <expC2> must then have the
            same length.

Library:    CT1.LIB


--------------------------------- Example ------------------------------

Examples:   * Replace all "123" for "ab"
            ? ATREPL(123,","123_123_123","ab")          && "ab_ab_ab"

            * Replace "123" by "ab" to the second
            * occurence inclusive.
            ? ATREPL(123,","123_123_123","ab",2)        && "ab_ab_123"

            * Replace only the second occurrence
            * of "123" by "ab"
            ? ATREPL(123,","123_123_123","ab",2,.T.)    && "123_ab_123"

            * Replace all "aa" for "a" and the effect
            * of CSETATMUPA().

            CSETATMUPA(.F.)
            ? ATREPL("aa","aaaa","a")                   && "aa"

            CSETATMUPA(.T.)
            ? ATREPL("aa","aaaa","a")                   && "a"



See Also: CSETATMUPA()

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