basic.occurs Function/BASIC Program

basic.occurs

Command basic.occurs Function/BASIC Program
Applicable release versions: AP
Category BASIC Program (486)
Description searches a string for attributes or values that occur consecutively.

The string that is searched is specified by "string.expression". "num.expression" is a numeric expression that specifies the number of occurrences. This function returns all substrings that occur at least the number of times specified by "num.exprression", delimited by the same mark as in the string.
Syntax occurs(string.expression, num.expression)
Options
Example
In this example, the "occurs" function evaluates the following string:

'22]11]11]11]22]11]11]22]11]11'  

(bracket (]) represents a value mark)

for n = 1 to 5
    substr=occurs(string,n)
    print n 'r%2' : ' ': substr
    print dcount(substr,vm):' string(s) occuring ':n:' 
time(s)'
next n

This code outputs the following:

01 22]11]22]11]22]11
6 string(s) occuring 1 time(s)
02 11]11]11
3 string(s) occuring 2 time(s)
03 11
1 string(s) occuring 3 time(s)
04
0 string(s) occuring 4 time(s)
05
0 string(s) occuring 5 times(s)

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.
Purpose
Related basic.col1
basic.statements
basic.count
basic.string.expression
basic.num.expression
basic.functions
basic.fold