Example: conditional compilation output

The following examples show the listings of a program that contains conditional compilation statements.

Start of changeExample 1End of change

Start of changeThis example shows the default conditional compilation output. The note numbers in the listing correspond to numbered explanations that follow the listing.End of change

  LineID  PL SL  ----+-*A-1-B--+----2----+----3----+----4----+----5----+----6----+----7-|--+----8 Map and Cross Reference
  
  000001                identification division.
  000002                program-id. prog.
  000003                data division.
  000004                working-storage section.
  000005                01 x pic 9(9) binary.
  000006                procedure division.
  000007                MainProgram.
  000008                    >>define var as 12
  000009                    >>evaluate var
  000010                    >>when 10
  000011               *           display 'var is 10'                    (1)
  000012                    >>when 11 thru 13
  000013                           display 'var is 11, 12 or 13'          (2)
  000014                    >>when other
  000015               *           display 'invalid value'                (1)
  000016                    >>end-evaluate
  000017                    goback.
  000018                end program prog.

(1)
Those branches of the EVALUATE directive were false at compile time, so the code in those branches was omitted from the resultant program.
(2)
That branch of the EVALUATE directive evaluated to true at compile time, so the code in that branch was included in the resultant program.
Start of change

Example 2

This example shows the conditional compilation output when CONDCOMP(SKIPSRC) is in effect. Notice that the false branches labeled with (1) in the previous example are omitted.

  LineID PL SL ----+-A-1-B--+----2----+----3----+----4----+----5----+----6----+----7-|--+----8 Map and Cross Reference

  000001             identification division.  
  000002             program-id. prog.
  000003             data division.
  000004             working-storage section.
  000005             01 x pic 9(9) binary.
  000006             procedure division.
  000007             MainProgram.
  000008                 >>define var as 12
  000009                 >>evaluate var
  000010                 >>when 10
  000012                 >>when 11 thru 13
  000013                        display 'var is 11, 12 or 13'           (2)
  000014                 >>when other
  000016                 >>end-evaluate
  000017                 goback.
  000018             end program prog.
End of change

Related references  
EVALUATE directive (Enterprise COBOL for z/OS® Language Reference)  
Conditional compilation (Enterprise COBOL for z/OS Language Reference)