%CHECKR (Check Reverse)
%CHECKR(comparator : base {: start {: *NATURAL | *STDCHARSIZE}})
%CHECKR returns the last position of the string base that contains a character that does not appear in string comparator. If all of the characters in base also appear in comparator, the function returns 0.
The check begins at the starting position and continues to the left until a character that is not contained in the comparator string is found. The starting position defaults to the end of the string.
The first parameter must be of type character, graphic, or UCS-2, fixed or varying length. The second parameter must be the same type as the first parameter. The third parameter, if specified, must be a non-float numeric with zero decimal positions.
The third or fourth parameter can be *NATURAL or *STDCHARSIZE
to override the current CHARCOUNT mode for the statement.
If this parameter is specified, it must be the last parameter.
- Specify *NATURAL to indicate that %CHECKR operates in CHARCOUNT NATURAL mode. The start position and return value are measured in characters rather than bytes or double bytes. For example, if the base string is a UTF-8 string with the value 'áxç', and the comparator string is 'çbá', the 'x' character is the first character found in the base string that does not appear in the comparator string. With CHARCOUNT NATURAL mode, %CHECKR returns 2, because the character 'x' is the second character in the base string.
- Specify *STDCHARSIZE to indicate that %CHECKR operates in CHARCOUNT STDCHARSIZE mode. In the previous example, with CHARCOUNT STDCHARSIZE mode, %CHECKR returns 3 because 'x' is the third byte in the string. Characters 'á' and 'ç' are 2-byte characters.
Note:
%CHECKR can also operate in CHARCOUNT NATURAL mode due to the
/CHARCOUNT compiler directive or the CHARCOUNT Control keyword.
For more information, see String Operations or Built-in Functions.