Loading

Easytrieve – check if value IS NUMERIC in an alpha variable

Similar to how we have the ‘IS NUMERIC’ verb in COBOL, we can validate if a Alphanumeric variable contains Numeric value or not in Easytrieve.

Sample program:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 DEFINE WS-ALPHA W 6 A
 JOB INPUT NULL
* ----- NOT NUMERIC --------
 WS-ALPHA = 'AB1234'
 IF WS-ALPHA NUMERIC
    DISPLAY WS-ALPHA ' IS NUMERIC'
 ELSE
    DISPLAY WS-ALPHA ' IS NOT NUMERIC'
 END-IF
* ----- NUMERIC --------
 WS-ALPHA = '123456'
 IF WS-ALPHA NUMERIC
    DISPLAY WS-ALPHA ' IS NUMERIC'
 ELSE
    DISPLAY WS-ALPHA ' IS NOT NUMERIC'
 END-IF
* ----- NOT NUMERIC --------
 WS-ALPHA = '123.45'
 IF WS-ALPHA NUMERIC
    DISPLAY WS-ALPHA ' IS NUMERIC'
 ELSE
    DISPLAY WS-ALPHA ' IS NOT NUMERIC'
 END-IF
* ----- NOT NUMERIC --------
 WS-ALPHA = '  1234'
 IF WS-ALPHA NUMERIC
    DISPLAY WS-ALPHA ' IS NUMERIC'
 ELSE
    DISPLAY WS-ALPHA ' IS NOT NUMERIC'
 END-IF
 STOP

Related Posts




blog comments powered by Disqus

There's 0 Comment So Far

Share your thoughts, leave a comment!