Function RAt() Foundation
Determines the position of last occurrence of a substring within a character string.
RAt( <cSeek>, <cString>, [<nStartPos>] ) --> nPosition
RAt() searches the character string <cString> from the end (from the right) and returns the last position of <cSeek> as an integer numeric value. When <cSeek> is not found in <cString>, the return value is zero.
The character function RAt() determines the last position of a character substring within another character string. <cString> is searched from the right. The counterpart of RAt() is the function At() which searches a character string from the left (beginning) and determines the position of the first occurrence of a character substring within another character string. The $ operator is also similar and tests whether or not a character string is contained within another.
The functions RAt() and At() are often used in connection with the functions SubStr(), Left() or Right() to perform character string operations.
// The example determines the path name from a
// complete file name.
PROCEDURE Main
LOCAL cFileName := "C:\XBASE\APPS\DBF\CUSTOMER.DBF"
? PathName( cFileName )
RETURN
FUNCTION PathName( cFileName )
LOCAL cPathName := ""
LOCAL nPosition := RAt( "\", cFileName )
IF nPosition > 0
cPathName := Left( cFileName, nPosition )
ENDIF
RETURN cPathName
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.