TESTN (Test Numeric)
Free-Form Syntax | (not allowed - rather than testing the variable before using it, code the usage of the variable in a MONITOR group and handle any errors with ON-ERROR. See Error-Handling Operations.) |
Code | Factor 1 | Factor 2 | Result Field | Indicators | ||
---|---|---|---|---|---|---|
TESTN | Character field | NU | BN | BL |
The TESTN operation tests a character result field for the presence
of zoned decimal digits and blanks. The result field must be a character
field. To be considered numeric, each character in the field, except
the low-order character, must contain a hexadecimal F zone and a digit
(0 through 9). The low-order character is numeric if it contains a
hexadecimal C, hexadecimal D, or hexadecimal F zone, and a digit (0
through 9). Note that the alphabetic characters J through R, should
they appear in the low-order position of a field, are treated as negative
numbers by TESTN. As a result of the test, resulting indicators are
set on as follows:
- Positions 71 and 72: The result field contains numeric characters; the low-order character may also be a letter from A to R, since these characters have a zone of C, D, or F, and a digit of 0 to 9.
- Positions 73 and 74: The result field
contains both numeric characters and at least one leading blank. For
example, the values ␢123 or ␢␢123 set this indicator
on. However, the value ␢1␢23 is not a valid numeric field
because of the embedded blanks, so this value does not set this indicator
on.
Note: An indicator cannot be specified in positions 73 and 74 when a field of length one is tested because the character field must contain at least one numeric character and one leading blank.
- Positions 75 and 76: The result field contains all blanks.
The same indicator can be used for more than one condition. If any of the conditions exist, the indicator is set on.
The TESTN operation may be used to validate fields before they are used in operations where their use may cause undesirable results or exceptions (e.g. arithmetic operations).
For more information, see Test Operations.