%CHECK(comparator : base {: start})
%CHECK returns the first 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 right until a character that is not contained in the comparator string is found. The starting position defaults to 1.
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.
For more information, see String Operations or Built-in Functions.
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
*--------------------------------------------------
* A string contains a series of numbers separated
* by blanks and/or commas.
* Use %CHECK to extract the numbers
*--------------------------------------------------
D string s 50a varying
D inz('12, 233 17, 1, 234')
D delimiters C ' ,'
D digits C '0123456789'
D num S 50a varying
D pos S 10i 0
D len S 10i 0
D token s 50a varying
/free
// make sure the string ends with a delimiter
string = string + delimiters;
dou string = '';
// Find the beginning of the group of digits
pos = %check (delimiters : string);
if (pos = 0);
leave;
endif;
// skip past the delimiters
string = %subst(string : pos);
// Find the length of the group of digits
len = %check (digits : string) - 1;
// Extract the group of digits
token = %subst(string : 1 : len);
dsply ' ' ' ' token;
// Skip past the digits
if (len < %len(string));
string = %subst (string : len + 1);
endif;
enddo;
/end-free
See also Figure 201.