Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper Tools . Books 1-3 - <b>beforatnum()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 BEFORATNUM()
 Returns the string segment before the nth occurrence of a sequence
------------------------------------------------------------------------------
 Syntax

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

 Arguments

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

     <cString>  Designates the string that is searched.

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

     <nIgnore>  Designates the nuber of characters that are eliminated
     from the search.  The default value ignores none (0).

 Returns

     The function returns all the characters in <cString> in front of the
     sequence determined.  If no corresponding sequence is found, then a null
     string is returned.

 Description

     This function determines the beginning position of the nth (<nCounter>)
     occurrence of <cSearchFor> within <cString> and returns the string
     segment before this sequence.  Additionally, the function takes into
     account the CSETATMUPA() setting, which can cause differing results.

     In order to determine the nth (<nCounter>) occurrence of the
     <cSearchFor>, BEFORATNUM() searches from the left for each instance of
     this sequence.  If CSETATMUPA() is off, then the search continues after
     the last character of the sequence most recently found.  If CSETATMUPA()
     is on, the search continues after the first character of the sequence
     most recently found.

 Note

     .  Implementing SETATLIKE() allows you to use wildcard characters
        within the search sequence.

 Examples

     .  Search a string for the last appearance of a sequence:

        ? BEFORATNUM("ab", "abcabdabe")                  // "abcabd"

     .  Search a string for the first occurrence of a sequence:

        ? BEFORATNUM("ab", "abcabdabe", 1)               // ""

     .  Search a string for the first occurrence of a sequence, where
        the first three characters are not considered in the search:

        ? BEFORATNUM("ab", "abcabdabe", 1, 3)            // "abc"

     .  Search a string for the third occurrence of "xx", where the
        first four characters are not considered!  Notice the different
        results when you use the multi-pass mode:

        String := "AxxBBBBxxCCCCxxxDxxEExx"

        CSETATMUPA(.T.)
        ? BEFORATNUM("xx", String, 3, 4)            // "AxxBBBBxxCCCCx"

        CSETATMUPA(.F.)
        ? BEFORATNUM("xx", String, 3, 4)            // "AxxBBBBxxCCCCxxxD"


See Also: CSETATMUPA() SETATLIKE()

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