VMS Help  —  MACRO  /ALPHA  Directives  .IF
    Conditional assembly block directive

    Format

      .IF  condition argument(s)
         .

         .

         .

      range
         .

         .

         .

      .ENDC

1  –  Parameters

 condition

    A specified condition that must be met if the block is to be
    included in the assembly. The condition must be separated from
    the argument by a comma, space, or tab.

 argument(s)

    One or more symbolic arguments or expressions of the specified
    conditional test. If the argument is an expression, it cannot
    contain any undefined symbols. The assembler converts relocatable
    arguments to absolute arguments by discarding the relocatable
    portion of the expression and using only the offset from the
    beginning of the psect. Arguments must be separated by a comma.

 range

    The block of source code that is conditionally included in the
    assembly.

    Table 7 Condition Tests for Conditional Assembly Directives

                                                             Condition
    Condition       Complement                     Number    That
    Test            Condition           Argument   of        Assembles
                    Test                Type       Arguments Block

    Long      Short               Short
    Form      Form  Long Form     Form

    EQUAL     EQ    NOT_EQUAL     NE    Expression 1 or 2    Expression-
                                                             1 is
                                                             equal to
                                                             expression-
                                                             2 or not
                                                             equal to
                                                             expression-
                                                             2.
    GREATER   GT    LESS_EQUAL    LE    Expression 1 or 2    Expression-
                                                             1 is
                                                             greater
                                                             than
                                                             expression-
                                                             2 or
                                                             less
                                                             than or
                                                             equal to
                                                             expression-
                                                             2.
    LESS_     LT    GREATER_      GE    Expression 1 or 2    Expression-
    THAN            EQUAL                                    1 is
                                                             less
                                                             than
                                                             expression-
                                                             2 or
                                                             greater
                                                             than or
                                                             equal to
                                                             expression-
                                                             2.
    DEFINED   DF    NOT_DEFINED   NDF   Symbolic   1         Symbol
                                                             is
                                                             defined
                                                             or not
                                                             defined.
    BLANK     B     NOT_BLANK     NB    Macro      1         Argument
                                                             is blank
                                                             or not
                                                             blank.
    IDENTICAL IDN   DIFFERENT     DIF   Macro      2         Arguments
                                                             are
                                                             identi-
                                                             cal or
                                                             differ-
                                                             ent.

2  –  Description

    A conditional assembly block is a series of source statements
    that are assembled only if a certain condition is met. A .IF
    starts the conditional block and a .ENDC ends the conditional
    block; each .IF must have a corresponding .ENDC. The .IF
    directive contains a condition test and one or two arguments.
    The condition test specified is applied to the arguments. If
    the test is met, all MACRO-64 statements between .IF and .ENDC
    are assembled. If the test is not met, the statements are not
    assembled. Optionally, you can use the .ELSE directive (or a
    combination of the .IFF, .IFT, and .IFTF directives) to specify
    an alternate series of statements to assemble if the test is not
    met.

    You can nest conditional blocks; that is, a conditional block
    can be inside another conditional block. In this case, the
    statements in the inner conditional block are assembled only
    if the condition is met for both the outer and inner block.

3  –  Notes

    o  The assembler displays an error message if the following
       directives occur outside a conditional assembly block: .ENDC,
       .ELSE, .IF_FALSE, .IF_TRUE, .IF_TRUE_FALSE.

    o  MACRO-64 permits a nesting depth of 100 conditional assembly
       levels. If a statement attempts to exceed this nesting level
       depth, the assembler displays an error message.

    o  The effect of logical expressions can only be achieved by
       using several levels of .IF directives. See Example 5.

    o  Lowercase string arguments are converted to uppercase before
       being compared, unless the string is surrounded by double
       quotes or /NAMES=AS_IS is specified on the command line.

    o  The assembler displays an error message if .IF specifies any
       of the following: a condition test other than those which are
       valid, an illegal argument, or a null argument specified in an
       .IF directive.

4  –  Examples

      Example 1
      Here is an example of a conditional assembly directive:

        .IF EQUAL  ALPHA+1        ; Assemble block if ALPHA+1=0. Do
          .                       ;   not assemble if ALPHA+1 not=0
          .
          .
        .ENDC
      Example 2
      Nested conditional directives take the following form:

        .IF   condition argument(s)
        .IF   condition argument(s)
          .
          .
          .
        .ENDC
        .ENDC
      Example 3
      The following conditional directives can govern whether
      assembly of the specified range is to occur:

        .IF DEFINED  SYM1
        .IF DEFINED  SYM2
          .
          .
          .
        .ENDC
        .ENDC

      In this example, if the outermost condition is not satisfied,
      no deeper level of evaluation of nested conditional statements
      within the program occurs. Therefore, both SYM1 and SYM2 must
      be defined for the specified range to be assembled.
      Example 4
      An alternate series of statements can be specified using .ELSE.

        .IF EQUAL A,B        ; Assemble if A is equal to B
        .ELSE                ; Assemble if A is not equal to B
        .ENDC

      Example 5
      The following example demonstrates the use of .ELSE and
      nesting:

        .IF LESS_THAN X,Y  ; Assemble if X is less than Y
           .IF DEFINED Z   ; Assemble if Z is defined and
                           ;  X is less than Y
           .ELSE           ; Assemble if Z is not defined and
                           ;  X is less than Y
           .ENDC
        .ELSE              ; Assemble if X is greater than or equal to Y
           .IF DEFINED Z   ; Assemble if Z is defined and X is
                           ;  greater than or equal to Y
           .ENDC
        .ENDC
Close Help