OCCURS


NCHAR

 

The OCCURS instruction scans a logical string counting the number of times that the source string is found. The instruction uses the following format:

 

 

[label]

OCCURS

{source}{sep}{search}{sep2}{result}

 

Where:

label

Optional. A Program Execution Label.

source

Required. A previously defined Character String Variable, National Character String Variable, literal, National Character String Literal, decimal number, or equated value for which to search.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

search

Required. A Character String Variable, National Character String Variable, Literal, or National Character String Literal whose logical string is searched for string comparisons as specified in the {source} parameter.

sep2

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, INTO, or GIVING.

result

Required. A Numeric Variable that receives the number of times that the {source} string is found in the {search} string.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. The {source} and {search} variables are not changed by the operation of this instruction.

  2. The EOS flag is set TRUE if the {source} or {search} variables are NULL and the {result} variable is set to zero.

  3. The ZERO flag is set if the search count stored in {result} is zero.

  4. The OVER flag is set TRUE if {result} is too small to receive the search count.

 

 

See Also: Example Code, Character String Instructions

 



PL/B Language Reference NOT OR