PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: DebugLevel[Next]: DuplicateParms
\ -> Commands -> #option -> DefineMacroReplace

DefineMacroReplace=OnOrOff

This #option command allows you to modify the way #define and #DefineRexx commands are processed.

Normally no replacement of any macros within its parameters are performed. This has its good points (which is why its the default) but at times you may wish to override this behavior. Apart from anything else in some cases this may speed things up.

If the "OnOrOff" parameter is empty then it defaults to the current default value, otherwise one of the following is expected:

Example


#define  AAAA   ValueAAAAOld
#define  BBBB   <$AAAA>          ;;Macro AAAA was not replaced
#option  DefineMacroReplace=ON   ;;When #define command executes replace any references to macros straight away.
#define  CCCC   <$AAAA>          ;;Macro AAAA was replaced
#define+ AAAA   ValueAAAANew     ;;Change Value of "AAAA"
#option DefineMacroReplace=''    ;;Set to the default value

;--- Use macros defined above -----------------------------------------------
<$BBBB>                          ;;Will generate "ValueAAAANew"
<$CCCC>                          ;;Will generate "ValueAAAAOld"

Example - Overcoming PPWIZARD Hang

The following is a fragment of a rexx program that supports a number of standard rexx operators (but not all). It is trying to build up a list of valid operators to display if the user chooses an unsupported one.

Because of the fact that by default a #define does not replace macros the following example would fail with an infinite loop (if the #option commands were removed).

/*--- Now compare --------------------------------------------*/
#define CompRepOperator                                    \
        when   sr_Operator = '{$Operator}' then           %\
               srCompRc = sr_bit {$Operator} sr_CompWith; -\
        #ifndef CSR_ValidList                             -\
                #define  CSR_ValidList  {$Operator}       -\
        #elseif                                           -\
                ;--- Careful or this line causes infinite loop ---    -\
                #define+ CSR_ValidList  <$CSR_ValidList>, {$Operator} -\
        #endif
select
    /*--- Test for supported compare operators ---------------------------*/
    #option PUSH DefineMacroReplace="ON"   ;;Used push/pop - Making no assumptions about current state
    <$CompRepOperator Operator='='>
    <$CompRepOperator Operator='<>'>
    <$CompRepOperator Operator='=='>
    <$CompRepOperator Operator='\=='>
    #option POP

    /*--- Not Valid ------------------------------------------------------*/
    otherwise
        Die("Unsupported operator of '" || sr_Operator || "' used", 'ONLY "<$CSR_ValidList>" are valid');
end;


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

[Top][Contents][Search][Prev]: DebugLevel[Next]: DuplicateParms


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