VMS Help  —  MACRO  /ALPHA  Directives  .IRPC  Example
      The macro definition is as follows:

            .macro X_COUNT ARG
                COUNT = 0
                .irpc CH,<ARG>
                    .iif identical,<CH>,<X>, COUNT = COUNT + 1
                .endr
            .endm X_COUNT

      The macro call and expansion of the macro defined previously is
      as follows:

            X_COUNT XXFOOXBARXX
                COUNT = 0
                .irpc CH,<XXFOOXBARXX>
                    .iif identical,<CH>,<X>, COUNT = COUNT + 1
                .endr
                    .iif identical,<X>,<X>, COUNT = COUNT + 1
                    .iif identical,<X>,<X>, COUNT = COUNT + 1
                    .iif identical,<F>,<X>, COUNT = COUNT + 1
                    .iif identical,<O>,<X>, COUNT = COUNT + 1
                    .iif identical,<O>,<X>, COUNT = COUNT + 1
                    .iif identical,<X>,<X>, COUNT = COUNT + 1
                    .iif identical,<B>,<X>, COUNT = COUNT + 1
                    .iif identical,<A>,<X>, COUNT = COUNT + 1
                    .iif identical,<R>,<X>, COUNT = COUNT + 1
                    .iif identical,<X>,<X>, COUNT = COUNT + 1
                    .iif identical,<X>,<X>, COUNT = COUNT + 1

                .print "%integer(COUNT)"
        %MACRO64-I-GENPRINT, Generated PRINT: 5

      This example uses the .IRPC directive to iterate over the
      characters in the argument to the X_COUNT macro. Each time
      an argument character is X, the variable COUNT is incremented.
      After the X_COUNT macro has expanded, the example uses the
      %INTEGER() lexical operator to display the value of COUNT.
Close Help