HELPLIB.HLB  —  MACRO  /ALPHA  Lexical Operators, Lexical Escape Operator
    It is possible to defer the processing of a lexical string
    operator by using the lexical escape operator, which is the
    percent sign (%).  Since all lexical string operators begin with
    a percent sign, the effect of placing two percent signs before
    the name of the lexical string operator defers the evaluation of
    the lexical string operator. If you want to defer processing of
    a lexical substitution operator, place two percent signs to the
    left and two percent signs to the right of the lexical string
    symbol name.

    This can be useful when you want the evaluation of a lexical
    string operator that you have used in a default macro argument
    to occur during macro expansion, rather than during macro
    definition. Lexical operator processing is suppressed during
    macro registration. Therefore, lexical operator processing is
    automatically deferred within the body of a macro. However, the
    .MACRO directive line that begins the macro definition is subject
    to normal lexical operator processing. Sometimes you may need
    to use the value of a lexical string symbol as the default for
    a macro argument, but you need to use the value of the lexical
    string symbol that is current when the macro expands, not when
    the macro is defined. Lexical Processing Without the Escape
    Operator shows an example of this, but it does not use an escape
    operator.

    Example 1  Lexical Processing Without the Escape Operator

        CODE_PSECT_NAME = "CODE1"
        .MACRO CODE_PSECT PSECT_NAME=%string(CODE_PSECT_NAME)
         .PSECT PSECT_NAME
        .ENDM CODE_PSECT
        CODE_PSECT
        CODE_PSECT_NAME = "CODE2"
        CODE_PSECT

    Lexical Processing Without the Escape Operator does not process
    correctly for the following reasons:

    o  The lexical operator in the .MACRO directive line is processed
       when the macro is defined, not when the macro expands.

    o  The CODE_PSECT macro always defaults to setting the psect
       to the CODE1 psect because the default for the PSECT_NAME
       argument will be set to CODE1, not %string(CODE_PSECT_NAME).
       This is because %string(CODE_PSECT_NAME) is evaluated when the
       CODE_PSECT macro is defined, not when it expands.

    Lexical Processing with Escape Operator is similar to Lexical
    Processing Without the Escape Operator except it uses the lexical
    escape operator.

    Example 2  Lexical Processing with Escape Operator

        CODE_PSECT_NAME = "CODE1"
        .macro CODE_PSECT PSECT_NAME=%%string(CODE_PSECT_NAME)
       .psect PSECT_NAME
        .endm CODE_PSECT
        CODE_PSECT
        CODE_PSECT_NAME = "CODE2"
        CODE_PSECT

    Lexical Processing with Escape Operator processes correctly for
    the following reasons:

    o  Lexical operator processing of %%string(CODE_PSECT_NAME)
       is deferred when the CODE_PSECT macro is defined. The
       default value for the PSECT_NAME argument is stored as
       %string(CODE_PSECT_NAME).

    o  During macro expansion, %string(CODE_PSECT_NAME) is evaluated,
       which results in the current value of the CODE_PSECT_NAME
       lexical string symbol as desired.
Close Help