COUNT
ANSI, NCHAR
The COUNT verb determines the number of significant characters that currently exist in a variable or list of variables. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
result
Required. A previously defined Numeric Variable that receives the results of the operation.
sep
Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.
source
Required. A previously defined Character String Variable, a National Character String Variable, a Numeric Variable, a list of string and/or numeric variables, or a VARLIST of string and/or numeric variables that is processed.
Flags Affected: OVER, ZERO
Note the following:
If the {result} is equal to zero, the ZERO Condition Flag is set.
If {result} is too small to contain the count, the OVER Condition Flag is set.
After the operation is finished, {result} contains the total number of significant characters that exist in all of the variables in {source}. Significant characters are determined by the descriptions in the Notes 4 and 5.
For numeric variables, the following rules apply:
Leading zeros and blanks are ignored.
After scanning over leading zeros and blanks, all remaining characters are counted except trailing zeros after the decimal point. If all characters after the decimal point are zeros, the decimal point is not included in the count.
For character string variables, the following rules apply:
Only the Logical String is counted.
Trailing spaces within the Logical String are then subtracted from the count.
Null Strings in {source} are ignored.
If an ARRAY variable is used in the list without a specific array element indicated, all array elements of the variable are used.
See Also: Example Code, Character String Instructions
![]() |