PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Multi Line Macros With Logic[Next]: Special Parameters
\ -> Macros -> Macro Indirection

Macro Indirection

The subject of macros is reasonably complex (but well worth learning) please ensure you have at least read the macro introduction before reading this section.

PPWIZARD provides an "array like" mechanism to allow you to replace parts of a macro reference. This provides another storage alternative to the rexx stem variables and the DataSave() and DataGet() routines.

When PPWIZARD sees a reference to a macro containing a string surrounded by square brackets (such as in "a.[b]"), it tries to replace the string (and brackets) with the contents of a rexx variable or PPWIZARD macro (in that order).

For example if the macro "c" contains "cccc" and the macro reference was to "a.[c]" then the "real" macro being referred to would be "a.cccc"! It is an error if "c" did not exist. PPWIZARD can handle any number of indirection levels as it will expand brackets from innermost to outermost.

You could use this facility to create a linked list. You could also use it to support multi language processing (although intelligent use of header files would possibly be easier).

The following are all valid (and "X" is expanded first):

Note that the use of square brackets is the default, you can use any two characters you wish, you can use the ReplacementTags option to modify them.

EXAMPLE

#define    A.N            B
#define    X              A
#define    TxtHello.en    Hello       ;;The text "Hello" in english
#define    lang           en

;--- Try some indirection ---
Expands A.N to give "B": <$[X].N>
#undef  [X].N
#define [X].N NewValue

;--- Say "hello" in current language ---
Hello in English       : <$TxtHello.[lang]>

Note that the dots used in the macro references above have no real significance, PPWIZARD does not care if you use them or not, I just think it makes things more "obvious".


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

[Top][Contents][Search][Prev]: Multi Line Macros With Logic[Next]: Special Parameters


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