OCCURS

OCCURS


num.expression Index Level OCONV
Syntax OCCURS( string.expression, num.expression )
Category BASIC
Type Function
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.
Options
See Also COL1() statements & functions COUNT string.expression num.expression functions FOLD
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.
Warnings
Compatibility D3 7.0 AP
num.expression Index Level OCONV