Condividi tramite


RAT( ) Function

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

RAT(cSearchExpression, cExpressionSearched [, nOccurrence])

Return Values

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

AT( ) | AT_C( ) | ATC( ) | ATCLINE( ) | ATLINE( ) | LEFT( ) | RATLINE( ) | RIGHT( ) | SUBSTR( ) | ATCC( ) | LEFTC( ) | RIGHTC( ) | SUBSTRC( ) | $ Operator | OCCURS( ) | INLIST( )