Skip to Content
Custom Search

COBOL EVALUATE TRUE

 

EVALUATE TRUE
 
The following COBOL program depicts the use of 
EVALUATE TRUE 
 
 
       PROGRAM-ID. PGM002.
       AUTHOR. MAINFRAMEWIZARD.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-SUB   PIC 9  VALUE ZEROS.
       PROCEDURE DIVISION.
       10000-MAIN-PARA.
             MOVE 5 TO WS-SUB.
             EVALUATE TRUE
                 WHEN WS-SUB>4
                  DISPLAY 'WS-SUB IS GREATER THAN 4'
                 WHEN WS-SUB>5
                  DISPLAY 'WS-SUB IS GREATER THAN 5'
                 WHEN OTHER
                  DISPLAY 'NO CONDITION MET'
             END-EVALUATE
             STOP RUN.
 
 
 
The ouput of the above program is 
 
 
WS-SUB IS GREATER THAN 4                                                                                                 
 
 
 
Note:- Control comes out of EVALUATE as soon as first satisfying condition is met.
 
If in the above case first condition was WS-SUB>1 and second condition was WS-SUB>2
then the control would have come out of EVALUATE as soon as WS-SUB>1 condition is met.
 
Try it yourself!!

Comments

Post new comment

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Click the +1 button  below to share it with your friends and colleagues

 

Share this if you liked it!

 

Disclaimer



Who's online

There are currently 0 users and 29 guests online.
Dr. Radut | page