PDA

View Full Version : Test Numeric



Guest.Visitor
07-23-2002, 04:45 AM
The <code>TESTN</code> opcode is a bit strange in that it will accept certain alphabetic characters as valid numeric. If you read the documentation for <code>TESTN</code> carefully, you'll see that it accepts characters other than '0'-'9' for the right-most digit. In particular, it accepts any character with zone nybble of '0'-'9' and sign nybble of hex 'C', 'D', or 'F' (in EBCDIC). Thus, characters '{', 'A'-'I', '}', and 'J'-'R' are accepted as the right-most digit. What to do? Best to use opcode <code>CHECK</code> or built-in function <code>%CHECK()</code> to ensure that all digits are in the range '0'-'9'. For example, the expression "<code>%CHECK('0123456789':%TRIMR(DATA))=0</code>" will have a value of <code>*ON</code> if the variable <code>DATA</code> has only digits and trailing spaces.

rkc@entrack.com
07-24-2002, 04:48 AM
Can anyone tell me the simplest way to check for numeric data in RPG. I have an 80 byte alpha field. The data will be left justified. If the data contains "1234" then I want to process. If the data contains "1234ABC" then I do not want to process. Will the TESTN operation work since I know I will have trailing blanks in the field? Thanks in advance. Ron

rkc@entrack.com
07-24-2002, 04:48 AM
Hans The CHECK function did the trick. Thanks.