*---------*---------------*-----------------*----------------*---------------* | CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS | | | | | FIELD | | *---------*---------------*-----------------*----------------*---------------* | CHECK | Comparator | Base | Left- | _ ER FD | | | string | string:start | position | | *---------*---------------*-----------------*----------------*---------------*
The CHECK operation verifies that each character in the base string (factor 2) is among the characters indicated in the comparator string (factor 1). Verifying begins at the leftmost character of factor 2 and continues character by character, from left to right. Each character of the base string is compared with the characters of factor 1. If a match for a character in factor 2 exists in factor 1, the next base string character is verified. If a match is not found, an integer value is placed in the result field to indicate the position of the incorrect character.
You can specify a start position in factor 2, separating it from the base string by a colon. The start position is optional and defaults to 1. If the start position is greater than 1, the value in the result field is relative to the leftmost position in the base string, regardless of the start position.
The operation stops checking when it finds the first incorrect character or when the end of the base string is encountered. If no incorrect characters are found, the result field is set to zero.
If the result field is an array, the operation continues checking after the first incorrect character is found for as many occurrences as there are elements in the array. If there are more array elements than incorrect characters, all of the remaining elements are set to zeros.
Factor 1 must be character, and can contain one of: a field name, array element, named constant, data structure name, data structure subfield, literal, or table name.
Factor 2 must contain either the base string or the base string, followed by a colon, followed by the start location. The base string portion of factor 2 must be character, and can contain: a field name, array element, named constant, data-structure name, literal, or table name. The start location portion of factor 2 must be numeric with no decimal positions, and can be a named constant, array element, field name, literal, or table name. If no start location is specified, a value of 1 is used.
The result field can be a numeric variable, numeric array element, numeric table name, or numeric array. Define the field or array specified with no decimal positions. The result field is an optional field; if you do not specify it, you must specify the found indicator in position 58-59.
Figurative constants cannot be used in the factor 1, factor 2, or result fields. No overlapping is allowed in a data structure for factor 1 and the result field or for factor 2 and the result field.
Any valid indicator can be specified in positions 7 to 17.
The indicator in positions 56-57 is turned on if an error occurs. The indicator in positions 58-59 is turned on if any incorrect characters are found.
Figure "CHECK Operation" shows examples of the CHECK operation.
*...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* Because factor 1 is a blank, CHECK indicates the position C* of the first nonblank character. If STRING contains 'bbbthe', C* NUM will contain the value 4. C* C ' ' CHECKSTRING NUM 20 *...1....+....2....+....3....+....4....+....5....+....6....+....7... I..............Namedconstant+++++++++C.........Fldnme......... .... I* I* After the following example, N=6 and the found indicator 90 I* is on. Because the start position is 2, the first nonnumeric I* character found is the '.'. I* I '0123456789' C DIGITS *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C MOVE '$2000.' SALARY C DIGITS CHECKSALARY:2 N 90
*...1....+....2....+....3....+....4....+....5....+....6....+....7... I..............Namedconstant+++++++++C.........Fldnme......... .... I* I* The following example checks that FIELD contains only the letters I* A to J. As a result, ARRAY=(136000) after the CHECK operation. I* Indicator 90 turns on. I* I 'ABCDEFGHIJ' C LETTER *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C MOVE '1A=BC*' FIELD 8 C LETTER CHECKFIELD ARRAY 90 C* C* In the following example, because FIELD contains only the C* letters A to J, ARRAY=(000000). Indicator 90 turns off. C* C MOVE 'FGFGFG' FIELD 8 C LETTER CHECKFIELD ARRAY 90
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.