%IF


ANSI

 

The Percent Conditional Compilation Directives allow the testing of conditions to determine if a section of PL/B code is included or excluded from the compilation process. They use the following formats:

 

(1)

%IF

{value1} {op} {value2}

(2)

%IF

{directive}({datalabel}) {op} {value1}

(3)

%ELSEIF

{value1} {op} {value2}

(4)

%ELSEIF

{directive}({datalabel}) {op} {value1}

(5)

%ELSE

 

(6)

%IFDEF

{datalabel}

(7)

%IFNDEF

{datalabel}

(8)

%IFZ

{value1},{value2},...,{valuen }

(9)

%IFZ

{directive}({datalabel}) {op} {value1}

(10)

%IFNZ

{value1},{value2},...,{valuen}

(11)

%IFNZ

{directive}({datalabel}) {op} {value1}

(12)

%ENDIF

 

(13)

CIF

{value1} {op} {value2}

(14)

CIF

{directive}({datalabel}) {op} {value1}

(15)

CELSEIF

{value1} {op} {value2}

(16)

CELSEIF

{directive}({datalabel}) {op} {value1}

(17)

CELSE

 

(18)

CIFDEF

{directive}({datalabel}) {op} {value1}

(19)

CIFNDEF

{directive}({datalabel}) {op} {value1}

(20)

CIFZ

{value1},{value2},...,{valuen}

(21)

CIFZ

{directive}({datalabel}) {op} {value1}

(22)

CIFNZ

{value1},{value2},...,{valuen}

(23)

CIFNZ

{directive}({datalabel}) {op} {value1}

(24)

CENDIF

 

 

Where:

value1

Required. A previously EQUATEd label, binary, decimal, octal, or hexadecimal value evaluated.

op

Optional. One of the following comparison operators: <, >, <=, >=, =, <>.

value2

Optional. A previously EQUATEd label, binary, decimal, octal, or hexadecimal value evaluated.

valuen

Optional. A previously EQUATEd label, binary, decimal, octal, or hexadecimal value evaluated.

directive

Optional. One of the compiler directives from the table below.

datalabel

Optional. A previously defined Data Definition Label.

Flags Affected: NONE

Note the following:

  1. Each of the instructions beginning with a C is an alternate form for the corresponding instruction beginning with a %.

  2. Each conditional compilation construct that begins with a %IF, %IFDEF, %IFNDEF, %IFZ, or %IFNZ instruction must be terminated with a %ENDIF instruction.

  3. Unlike the IF directives, the %ENDIF instruction only terminates the most current %IF directive.

  4. The %ELSEIF and %ELSE instruction are only allowed while a %IF construct is active. Any number of %ELSEIF instructions may be used and one %ELSE instruction may be used. If the %ELSE instruction is used, it must be after all %ELSEIF instructions for the given construct.

  5. At least one space is required between {value1} and {op}, and between {op} and {value2}.

  6. %IF directives may be nested up to one hundred (100) levels deep.

  7. For a given construct, at most only one group of instructions is compiled by the compiler. In the case where there are multiple %ELSEIF instructions that would evaluate to a true condition, only the first one to evaluate to a true condition is compiled.

  8. The %IFDEF and %IFNDEF instructions test whether a {datalabel} has been declared. If the {datalabel} operand of these directives is not terminated by a blank character, a compiler warning is given by default when the program is compiled. If the compiler option '-B' is specified, the compiler gives an error rather than a warning.

  9. The %IFZ and %IFNZ instructions allow for testing the value of one or more equated variables. In the case of the %IFZ instruction, if any variable is zero, the instruction is true. In the case of the %IFNZ instruction, if any variable is not zero, the instruction is true.

  10. Valid {directives} are as follows:

  11.  

    Directive

    Retrieves ...

    DTYPE

    a sixteen-bit value representing the type of the data variable. The type values can be found in the PLBEQU.INC include file.

    DTYPEBASE

    an eight-bit value representing the base type value of {dataLabel} variables. These equated values can be found in the PLBEQU.INC include file.

    DTYPESUB

    an eight-bit value representing the subtype value of {dataLabel} variables. Only some variables have subtypes. These equated values can be found in the PLBEQU.INC include file.

    ATYPE

    a value that identifies whether a {dataLabel} variable is an array variable. If a value of zero is retrieved, the variable is not an array. Otherwise, the value represents the total number of elements in the array.

    PTYPE

    a value that indicates whether the variable is a pointer. A value of zero indicates that a variable is not a pointer.

    DEFINED

    The results of a DEFINED compiler directive.

    MDEFINED

    The results of a MDEFINED compiler directive.

    MDEFAULT

    The results of a MDEFAULT compiler directive.

    MPARAMNUM

    The results of a MPARANUM compiler directive.

 

See Also: Example Code, IF, Compiler Directives

 



PL/B Language Reference IF INCLUDE