occurs() Function

The occurs() function searches a string for attributes or values that occur consecutively.

Syntax

occurs(str.exp, num.exp)

Parameter(s)

str.exp

String to search.

num.exp

Numeric expression that specifies the number of occurrences.

Description

This function returns all substrings that occur at least the number of times specified by num.exp, delimited by the same mark as in the string.

Example(s)

The ] represents a value mark.

string = ’22]11]11]11]22]11]11]22]11]11’

 

for n = 1 to 5

substr=occurs(string,n)

print n ’r%2’ : ’ ’: substr

print dcount(substr,@vm):’ string(s) occurring ’:n:’ time(s)’

next n

This code outputs:

01 22]11]22]11]22]11

6 strings occurring 1 time.

02 11]11]11

3 strings occurring 2 times.

03 11

1 string occurring 3 times.

04

0 strings occurring 4 times.

05

0 strings occurring 5 times.

The output for line 01 is each time string is found at least once in a series. On line 02, the substring 11 is found to occur in a series of 2 at least twice in the major string. The string 11 is also found in a series of 3 one time. No 4 or 5 repetitive series are found.

See Also

col1() Function

count() Function

fold() Function

BASIC Functions

Numeric Expressions

Statements and Functions