On RPG-LE Development

Postings on RPG-LE and i5/OS

Posts Tagged ‘RPGLE Check for Alpha or Numeric

Checking for Alpha or Numerics using %CHECK

leave a comment »

SYNTAX: %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.

Using the example code below, %CHECK begins scanning with the first character of ‘BR459’, the base string. Since ‘B’ is not found in the comparator string the scan will stop and POS will contain 1.

POS = %Check( ‘0123456789 ‘ : ‘BR549’);

From the result, we can say ‘BR549’ is not numeric.


Written by Ben

2010/12/22 at 10:07 am