Check: Finally, string checking is the process of determining if all the characters in the string belong to a certain set of characters. For instance, you can check that a given string (which is supposed to contain a hexadecimal notation like “12F6”) only contains the valid hexadecimal nybbles 0 to 9 and A to F.
RPG performs this function with the CHECK operation. Factor 1 is a string containing all the characters that are considered valid. Factor 2 contains the string to be checked, with an optional :n extension if you want to start checking at a certain position. The result field can contain either a numeric field or a numeric array, which will have the position(s) of the invalid characters found in the string. If all characters in the string are valid, the result field is zero. If you use a numeric array, CHECK reports multiple occurrences of invalid characters. An optional indicator in columns 56-57 can be used to monitor for an invalid condition such as a starting position beyond the end of the string.
CL has no equivalent of the CHECK operation.