Xbasic

RAT Function

Syntax

Position as N = RAT(C substring,C string[,N occurance])

Arguments

substring

The character string to find.

string

The character string to examine for occurrences of the substring.

occurance

Optional. Default (1). The instance of the substring to find. Numeric

Description

Returns the position of one string found in another, relative from the end of the string.

Discussion

The RAT() function searches backwards through the string looking for the n th occurrence of the substring ; where n is specified through the occurance argument. If the substring is found, then RAT returns its Position, a numeric value that equals the number of characters from the end of the string at which the substring starts. If no match is found, RAT returns 0. Occurance is an optional argument, and if omitted the first occurrence of the substring will be returned. The substring argument is case sensitive.

Example

? rat("word", "word1 word2 word3", 1)
= 5
? rat("word", "word1 word2 word3", 2)
= 11
? rat("word", "word1 word2 word3", 3)
= 17
? rat("word", "word1 word2 word3", 4)
= 0
? rat("O'Neill", "Timothy P. O'Neill")
= 7
? rat("case", "CaSe SeNsItIve")
= 0

See Also