PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: {$?} - Expand All Unused Parameters[Next]: {<?x24>?MACNAME} - Expand Macro Name
\ -> Macros -> Special Parameters -> {$??} - Expand All Parameters As Rexx Code

{$??} - 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 #1

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

Example #2 - Real Life

I am developing some site mapping macros which will hopefully allow you to do amazing things (other than just site mapping and determining next and previous pages).

The macros will hopefully allow allow you to automatically build tree based navigation code and allow user extension of site and page information via user attributes.

The macros will (of course) not know the names of the user parameters and will simply store these for easy user retrieval.

The following is one of the early revisions of the site macro:

#(
   #define Site

   ;--- Handle the parameters ---
   #evaluate ^^ ^<$Rexx4SiteMacro {$?}>^
#)
#DefineRexx 'Rexx4SiteMacro'
   ;--- Some debug info ---
   call Debug 'Macro: Rexx4SiteMacro'
   call DebugInc

   ;--- Increase the "nesting" level ---
   call StackPush 'SITE MACRO'
   @@SiteLevel = @@SiteLevel + 1;

   ;--- Remember the name of this site ---
   #if '<?OpSys>' = 'UNIX'
       @@ThisSite = '{$#1}';
   #else
       @@ThisSite = translate('{$#1}');      ;;Fixed case in non unix operating systems!
   #endif
   call Debug 'SITE = ' || @@ThisSite

   ;--- Flag the fact that we have details for this site ---
   @@SiteKey = '@@SITE_' || c2x(@@ThisSite);
   call value @@SiteKey, '{$Name=^{$#1}^}';  ;;Save the site's name under the alias

   ;--- Initialize the page count ---
   @@PageCntKey = @@SiteKey || '_PAGECNT';
   call value @@PageCntKey, '0';

   ;--- Put SiteKey on the stack ---
   @@Site.@@SiteLevel = @@SiteKey

   ;--- Remember all of the sites attributes ---
   {$??}                  ;;Expands all parameters
   do  @@x = 1 to MP.0
       if  MP.@@x.MPUSED <> 'Y' then
       do
           ;--- Save the attribute ---
           call Debug 'ATTRIBUTE ' || MP.@@x.MPNAME || ' = ' || MP.@@x.MPVALUE;
           @@SiteAttrKey = @@SiteKey || '_' || MP.@@x.MPNAME;
           call value @@SiteAttrKey, MP.@@x.MPVALUE;
       end;
   end;

   ;--- Restore debug level ---
   call DebugDec;
#DefineRexx

This is an example of it (and the page macro) being used:

<$Site "SITENAME"   \
       a='aaaa'     \
       b='bbbb'     \
>
   <$Page "FRED_1ST"  TITLE="Page FRED_1ST"  attr1="1" attr2="2">
   <$Page "FRED_MID"  TITLE="Page FRED_MID"  attr1="1" attr2="2">
   <$Page "FRED_LAST" TITLE="Page FRED_LAST" attr1="1" attr2="2">
<$/Site>


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

[Top][Contents][Search][Prev]: {$?} - Expand All Unused Parameters[Next]: {$?MACNAME} - Expand Macro Name


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