Compartir a través de


RAT( ) Function

Returns the numeric position of the last (rightmost) occurrence of a character string within another character string.

RAT(cSearchExpression, cExpressionSearched [, nOccurrence])

Return Value

Numeric

Parameters

  • cSearchExpression
    Specifies the character expression that RAT( ) looks for in cExpressionSearched. The character expression can refer to a memo field of any size.

  • cExpressionSearched
    Specifies the character expression that RAT( ) searches. The character expression can refer to a memo field of any size.

  • nOccurrence
    Specifies which occurrence, starting from the right and moving left, of cSearchExpression RAT( ) searches for in cExpressionSearched. By default, RAT( ) searches for the last occurrence of cSearchExpression (nOccurrence = 1). If nOccurrence is 2, RAT( ) searches for the next to last occurrence, and so on.

Remarks

RAT( ), the reverse of the AT( ) function, searches the character expression in cExpressionSearched starting from the right and moving left, looking for the last occurrence of the string specified in cSearchExpression.

RAT( ) returns an integer indicating the position of the first character in cSearchExpression in cExpressionSearched. RAT( ) returns 0 if cSearchExpression isn't found in cExpressionSearched, or if nOccurrence is greater than the number of times cSearchExpression occurs in cExpressionSearched.

The search performed by RAT( ) is case-sensitive.

Example

STORE 'abracadabra' TO string
STORE 'a' TO find_str
CLEAR
? RAT(find_str,string)  && Displays 11
? RAT(find_str,string,3)  && Displays 6

See Also

Reference

AT( ) Function

AT_C( ) Function

ATC( ) Function

ATCLINE( ) Function

ATLINE( ) Function

LEFT( ) Function

RATLINE( ) Function

RIGHT( ) Function

SUBSTR( ) Function

ATCC( ) Function

LEFTC( ) Function

RIGHTC( ) Function

SUBSTRC( ) Function

$ Operator

OCCURS( ) Function

INLIST( ) Function

Other Resources

Functions