Supported RPG Features

/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 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.