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 5.3 . Guide To CA-Clipper - <b>rat()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 RAT()
 Return the position of the last occurrence of a substring
------------------------------------------------------------------------------
 Syntax

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

 Arguments

     <cSearch> is the character string to be located.

     <cTarget> is the character string to be searched.

 Returns

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

 Description

     RAT() is a character function that returns the position of the last
     occurrence of a character substring within another character string.  It
     does this by searching the target string from the right.  RAT() is like
     the AT() function, which returns the position of the first occurrence of
     a substring within another string.  RAT() is also like the $ operator,
     which determines whether a substring is contained within a string.

     Both the RAT() and AT() functions are used with SUBSTR(), LEFT(), and
     RIGHT() to extract substrings.

 Examples

     .  This example uses RAT() to create a user-defined function,
        FilePath(), that extracts the path from a file specification.  If the
        path is unspecified, FilePath() returns a null string (""):

        ? FilePath("C:\DBF\Sales.dbf")      // Result: C:\DBF\

        FUNCTION FilePath( cFile )
           LOCAL nPos, cFilePath
           IF (nPos := RAT("\", cFile)) != 0
              cFilePath = SUBSTR(cFile, 1, nPos)
           ELSE
              cFilePath = ""
           ENDIF
           RETURN cFilePath

 Files   Library is EXTEND.LIB.


See Also: RIGHT() STRTRAN() SUBSTR()

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