VMS Help  —  MACRO  /ALPHA  Directives  .NARG
    Number of arguments directive

    Format

      .NARG  symbol

1  –  Parameter

 symbol

    A symbol that is assigned a value equal to the number of
    positional arguments in the macro call.

2  –  Description

    .NARG determines the number of arguments in the current macro
    call.

    .NARG counts all the positional arguments specified in the macro
    call, including null arguments (specified by adjacent commas).
    The value assigned to the specified symbol does not include
    any keyword arguments or any formal arguments that have default
    values.

3  –  Notes

    o  If .NARG appears outside a macro, the assembler displays an
       error message.

4  –  Examples

      Example 1
      The macro definition is as follows:

        .MACRO  CNT_ARG A1,A2,A3,A4,A5,A6,A7,A8,A9=DEF9,A10=DEF10
        .NARG   COUNTER         ; COUNTER is set to no. of ARGS
        .WORD   COUNTER         ; Store value of COUNTER
        .ENDM   CNT_ARG
      Example 2
      The macro calls and expansions of the macro previously defined
      are as follows:

        CNT_ARG TEST,FIND,ANS   ; COUNTER will = 3
        .NARG   COUNTER         ; COUNTER is set to no. of ARGS
        .WORD   COUNTER         ; Store value of COUNTER

        CNT_ARG                 ; COUNTER will = 0
        .NARG   COUNTER         ; COUNTER is set to no. of ARGS
        .WORD   COUNTER         ; Store value of COUNTER

        CNT_ARG TEST,A2=SYMB2,A3=SY3      ; COUNTER will = 1
        .NARG   COUNTER         ; COUNTER is set to no. of ARGS
        .WORD   COUNTER         ; Store value of COUNTER
                                ; Keyword arguments are not counted

        CNT_ARG ,SYMBL,,        ; COUNTER will = 4
        .NARG   COUNTER         ; COUNTER is set to no. of ARGS
        .WORD   COUNTER         ; Store value of COUNTER
                                ; Null arguments are counted
Close Help