/CHARCOUNT NATURAL and /CHARCOUNT STDCHARSIZE select how the statements
after the directive count string positions and lengths - the same choice the
string built-ins take as a trailing argument (see
The character-counting mode).
The operand carries no asterisk. NATURAL, not *NATURAL; the asterisk
belongs to the BIF argument only. Any other word is
TRN0018.
/CHARCOUNT NATURAL requires CHARCOUNTTYPES() to name at least one data type,
otherwise the mode would apply to nothing - also TRN0018. STDCHARSIZE needs no
such list.
Three scoping rules:
- The mode is lexical: it applies from the directive to the next one, and a source may switch back and forth as often as it likes.
- An explicit BIF argument overrides whatever directive is in force, in either direction.
- The mode is not restored at a
/COPYboundary. A copy member that switches the mode leaves it switched for the statements after the copy. This is the opposite of/SET, which does restore - do not assume the two behave alike.
The directive works in free-format members and in fixed-format members, where - like every other directive - it goes in column 7.
/CHARCOUNT NATURAL
n = %scan('b' : value); // counts characters
/CHARCOUNT STDCHARSIZE
n = %scan('b' : value); // counts standard characters
As with the BIF argument, the two modes select the same positions for
single-byte data, so the directive is accepted and changes nothing there. An
operand declared CCSID(*UTF8) is accepted with either mode: *NATURAL counts
characters and *STDCHARSIZE counts standard character size. Source that names
no mode at all is unaffected.