ISO2002ENTMF 

Appendix A - Examples of Conditional Compilation

The following excerpts show some examples of conditional compilation in effect.

Example 1:

This example is dependent on the DEFINE Compiler option setting the 64BIT variable (DEFINE 64BIT (TRUE)). If it is set, the INIT64 program is called:

...
   >>DEFINE 64BIT AS PARAMETER
...
   >>IF 64BIT IS DEFINED
       CALL "INIT64"
   >>ELSE
       CALL "INIT32"
   >>END-IF
...

Example 2:

In this example, the variables are defined inline, and so do not need to be defined using the DEFINE Compiler option. This excerpt demonstrates that you can use the OVERRIDE keyword to change the value of a defined variable:

...
   >>DEFINE VAR AS 10
...
   >>DEFINE VAR AS VAR - 2 OVERRIDE
   >>IF VAR = 10
     DISPLAY "FAIL"
   >>ELSE 
     DISPLAY "PASS"
   >>END-IF
...

Example 3:

Again, the variable is defined inline, and shows the EVALUATE directive, which produces "PASS". If you used the EVALUATE FALSE construct, the result would be reversed (that is, display "FAIL"):

...
   >>DEFINE VAR2 as 10 * 2
...
   >>EVALUATE TRUE

   >>WHEN VAR2 > 12
       DISPLAY "PASS"
   >>WHEN VAR2 < 12
       DISPLAY "FAIL"	
   >>END-EVALUATE
...

Example 4:

This example uses two variables within the EVALUATE directive, executing the clause indicated below.

...
   >>DEFINE VAR1 AS 3
   >>DEFINE VAR2 AS 1
...
   >>EVALUATE VAR1
   >>WHEN VAR2+1
       COMPUTE X = X + (X * 0.20)
   >>WHEN VAR2+2
       COMPUTE X = X + (X * 0.40)  *> this clause is executed
   >>WHEN VAR2+3
       COMPUTE X = X + (X * 0.45)
   >>WHEN OTHER
       COMPUTE X = X
   >>END-EVALUATE
DISPLAY X.
...