![]() | ![]() | ![]() | ![]() | ![]() |
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:
The command applies to the complete contents of a macro before any replacement of parameters has occurred.
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:
It should be noted that under regina there is a limitation that a long string could break so I now recommend the use of "$$RX'" instead.
To define a format you need to define a macro which contains the rexx formatting code. The macro must have the name of "REXX_$$" followed by the name of your command, for example to use the command "$$TO_C_STRING" you would create "REXX_$$TO_C_STRING". The value to be formatted is in the "TheValue" variable.
If required you can also determine the source of the value (macro or parameter name) as it is stored in "TheName" (for case insensitive items it is in upper case). For macro parameters only the name of the macro being expanded is in the "TheMacro" variable.
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'>
![]() | ![]() | ![]() | ![]() | ![]() |