%IF Example


Example 1:

 

  

%IFZ

FLAG1

  

  (line 1)

 

  

  (line 2)

 

  

  %IF

  FLAG2 = 1

  

    (line 3)

 

  

    (line 4)

 

  

    (line 5)

 

  

  %ELSEIF

  FLAG2 = 2

  

    (line 6)

 

  

  %ELSEIF

  FLAG2 = 3

  

    (line 7)

 

  

    (line 8)

 

  

  %ELSE

 

  

    (line 9)

 

  

  %ENDIF

 

  

%ENDIF

 

 

Lines 1 and 2 are compiled only if FLAG1 is 0. Lines 3 through 5 are compiled only if FLAG1 is 0 and FLAG2 is 1. Line 6 is compiled only if FLAG1 is 0 and FLAG2 is 2. Lines 7 and 8 are compiled only if FLAG1 is 0 and FLAG2 is 3. Line 9 is compiled only if FLAG1 is 0 and FLAG2 is not 1, 2, or 3. The %ENDIF directive terminates only the current conditional compilation.

Example 2:

 

  

%IF

DTYPE(file) = $T_IFILE

  

  DISPLAY

"IFILE"

  

%ENDIF

 

 

If the type of the variable "file" is IFILE, a message is displayed.

Example 3:

 

  

%IFZ

DEFINED(ABC)

  

  DISPLAY

"Something"

  

%ENDIF

 

 

This example illustrates the user of a language directive as an operand.

 



PL/B Language Reference IFILE Examples IMAGE Example