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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.