![]() | ![]() | ![]() | ![]() | ![]() |
Expand All Parameters As Rexx Code |
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.
This section describes an advanced rarely used or required facility which allows you to write a macro that can take variable parameters with unknown names etc. This is useful in cases where the macro logic is very generic but can be applied for an unknown number of parameters or parameters whose names may change (as the name itself is significant for the generated code).
The parameter information that is expanded by "{$??}" is in the form of rexx code initializing an array (stem). This means that you would normally require rexx code to process the information.
The information generated is as follows (where '?' represents a number 1 to 'n'):
Note that "MP.0" holds the value of 'n', that is the number of parameters stored. Any "$$" commands are unfortunately ignored, tell me if you have problems with this.
To allow you to use it any number of times, this parameter does not mark all the parameters as used. It does however disable any {$!} validation for the macro.
Example |
This example code shows how the parameter is used and what it expands to but does not show the generated array being used in any way.
The source code:
#define TestQmQm {$??} *** 0 PARMS ***** <$TestQmQm> *** SOME PARMS ***** <$TestQmQm "Parm1IsPositional 1" Parm2HasNoValue Parm3="Parm3Value">
Generates:
*** 0 PARMS ***** MP.0 = 0 *** SOME PARMS ***** MP.1.MPNAME = '#1' MP.1.MPVALUE = 'Parm1IsPositional 1' MP.1.MPUSED = 'N' MP.1.MPTYPE = 'V' MP.2.MPNAME = 'Parm2HasNoValue' MP.2.MPVALUE = 'PARM2HASNOVALUE' MP.2.MPUSED = 'N' MP.2.MPTYPE = 'NV' MP.3.MPNAME = 'Parm3' MP.3.MPVALUE = 'Parm3Value' MP.3.MPUSED = 'N' MP.3.MPTYPE = 'V' MP.0 = 3
The "Row" macro in my "WISEINST.WIH" is built around this facility.
![]() | ![]() | ![]() | ![]() | ![]() |