Loading

simple and nested IF-ELSE-ENDIF statement in Easytrieve

IF ELSE ENDIF statement in Easytrieve is similar to how we do in COBOL.

Below are some sample programs that will help you understand.

 LIST ON
 DEFINE WS-FIVE W 5 N VALUE 5
 JOB INPUT NULL
 IF WS-FIVE EQ 5
    DISPLAY 'WS-FIVE IS 5'
 END-IF
 STOP
 LIST ON
 DEFINE WS-FIVE W 5 N VALUE 5
 JOB INPUT NULL
 IF WS-FIVE EQ 5
    DISPLAY 'WS-FIVE IS 5'
 ELSE 
    DISPLAY 'WS-FIVE IS NOT 5'
 END-IF
 STOP
 LIST ON
 DEFINE WS-NUM W 5 N VALUE 6
 JOB INPUT NULL
 IF WS-NUM EQ 5
    DISPLAY 'WS-NUM IS 5'
 ELSE 
    IF WS-NUM EQ 6
       DISPLAY 'WS-NUM IS 6'
    ELSE 
       DISPLAY 'WS-NUM IS NOT 5 OR 6'
    END-IF
 END-IF
 STOP

Related Posts




blog comments powered by Disqus

There's 0 Comment So Far

Share your thoughts, leave a comment!