PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Expand Macro Name[Next]: Macro Indirection

Macro Tranformations

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 a mechanism to hold macro data in one format but transform this data when tranformed, this removes the need to hold the same data in multiple formats.

Transformation commands all start with $$ and apply to:

  1. Macro Replacement
    Macros parameter where they were supplied on a reference without a value that and begin with '$$' have special meaning, they are commands to PPWIZARD.

    The command applies to the complete contents of a macro before any replacement of parameters has occurred.

  2. Macro Parameter Replacement

Restriction

Note that most of the above '$$' commands work directly on the contents of the macro (after parameter substitution). If the contents (or parameters) contained macros then you may not get the desired affect.

The Available $$ Tranformations

In the following list "Bold $$ commands" apply to both macro and parameter replacement, "Dark Green $$ commands" only apply to macro replacement and "Magenta $$ commands" only apply to macro parameter replacement:

Note that the quoting routines above do more than just make your code "prettier", without using these commands you have to decide on a quote character yourself and then a parameters value must never contain this character. These special commands won't solve all quoting issues (remember parameter processed left to right - imbedded parameters are not processed first) however they will make life much easier.

EXAMPLE - $$ Macro Replacement

If you haven't a clue what this is about, cut and paste the following and try it:

    ;--- Need to have access to mixed, lower and upper case values ---
    #define  MixedCase  Dennis Was Here
    ;#define LowerCase  dennis was here
    ;#define UpperCase  DENNIS WAS HERE
    
    ;--- Output the 3 formats ---
    Mixed case = <$MixedCase>
    Lower case = <$MixedCase $$lower>
    Upper case = <$MixedCase $$upper>
    

A simple example where if the "$$SQX2" command were not used that ppwizard would fail (in this case with variable "A" unknown trap):

    #define TheMacro   The value 'A' is in quotes
    #evaluate "" "call Summary 'VALUE', '<$TheMacro $$SQx2>'"
    

Another example where we wish to add commas to a rexx variable:

    Value = <??ARexxVariable $$ADDCOMMA>
    

Here is another example which may be useful if you were creating 'C' code and maybe other situations:

    ;--- Define directory (non 'C' format as used elsewhere) ---
    #define DIR_NAME     C:\DB\PROJECTS\FRED
    
    ;--- Define a macro to transform a string into 'C' format ---
    #DefineRexx REXX_$$TO_C_STRING
                TheValue = ReplaceString(TheValue, '\',     '\\');
                TheValue = ReplaceString(TheValue, '"',     '\"');
                TheValue = ReplaceString(TheValue, d2c(10), '\n');
                TheValue = ReplaceString(TheValue, d2c(13), '\r');
                TheValue = ReplaceString(TheValue, d2c(7),  '\b');
    #DefineRexx
    
    ;--- Use our defined transformation ---
    StringC = "<$DIR_NAME $$TO_C_STRING>";
    

EXAMPLE - $$ Parameter Replacement

Lets make sure that parameters 2 and 3 in the following macro get translated to upper case:

    ;--- Define macro ---------
    #define  SimpleTest P1={$parm1}, P2={$parm2="parm1_default" $$upper}, P3={$parm3 $$upper $$DSQ}
    
    ;--- Expand macro ---------
    <$SimpleTest Parm1='value1' Parm2='value2' Parm3='value3'>
    


[Top][Contents][Search][Prev]: Expand Macro Name[Next]: Macro Indirection

PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Thursday January 17 2002 at 6:27pm