PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Examples / Tips[Next]: Adding Dependencies via a File Mask
\ -> Examples / Tips -> A Macro Which Expands Another

A Macro Which Expands Another

Sometimes you wish to delay the expansion of a macro. This might be so that you can display a symbols name as well as refer to its value.

The following is a very simple macro which expands a macro whose name is passed:

;--- Expands a macro (macros name is passed) ---
#define ExpandMacro <${$#1}>

The following macro makes use of the above macro to display the color name in a "C" style comment as well as expanding the color into the integer some fictional subroutine requires:

;--- Define a macro to change color ------------
#define RED    1
#define GREEN  2
#define BLUE   3
#define ChangeColor                               \
        /*--- The color used was "{$#1}" ---*/   %\
        ChangeColor(<$ExpandMacro "{$#1}">);

This:

<$ChangeColor "RED">

Expands to:

/*--- The color used was "RED" ---*/
ChangeColor(1);


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: Examples / Tips[Next]: Adding Dependencies via a File Mask


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Saturday May 28 2022 at 2:55pm