Return to the RPG Tips
Test for valid positive numbers
'12G' is a character representation of the number -127. When you MOVE a negative number to a character field, it changes the value of the "zone" portion of rightmost byte to reflect that its a negative number. (The change will usually result in a letter from A-R or the "{" character.)
Therefore "12G" is a valid number.
If you only want to test for valid positive numbers, do something like this:
C MOVEL '12G' SIN 3 C MOVE *zeros WORK 4 C MOVEL SIN WORK C TESTN WORK 81 c eval *inlr = *onBy putting that extra zero at the end, the "G" ends up in the middle of the number, and will signal an error.
[report a broken link by clicking here]