Xbasic

OCCURS Function

Syntax

Count as N = OCCURS(C searchfor,C searchin)

Arguments

searchfor

The character string to find and count.

searchin

The character string to examine.

Description

Returns the number of times one string is found in another.

Discussion

OCCURS() returns the number of times the Find_String is found in the Search_In_String. The Search_In_String cannot be a memo field.

Example

occurs("i", STATE) -> 4, if STATE contains "Mississippi"
occurs("at", "The cat in the hat") -> 2
occurs("ab", "ABCDabcd") -> 1
dim lst as C
lst = 
alpha
beta
alpha
gamma
%str%
? occurs("alpha", lst)
= 2

Limitations

The Find_String argument is case sensitive.

See Also