PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Quoted Text - $The$Rest$[Next]: Simplest Macros
\ -> Macros

Macros

The "#include" command allows you to include external files (whole or selected fragments) so this would have to be the simplest and common way of obtaining code reuse and this is where facilities such as SSI (Server Side Includes) stop. PPWIZARD can do much more than this.

Macros are collections of text and/or commands and would have to be one of the most important and most used features of this preprocessor.

The most common ways of creating macros are with these methods:

  1. #define[+]
  2. #evaluate[+]
  3. /define

The simplest types of macro simply allows you to define text which you will use over and over again. You will want to specify it in one place so that if it ever changes you won't need to hunt up all occurances. The following example shows an email address being defined (this would normally be done in a central place and be accessed with #include):

#define MyEmailAddress           dbareis@labyrinth.net.au

Now that we have defined the email address (once as per example above), in all the html pages that required it we could refer to it like:

<P>If you have any questions or suggestions for improvements please feel free to
<A HREF="mailto:<$MyEmailAddress>">email me</A>.

There are also a number of "Standard Macros" which always exist, these allow you to easily obtain information about the current time or files being generated or included. All sorts of useful information is available in standard formats, if you don't like the format of a particular item such as the "compile time" then it is a simple matter to use ppwizard to create your own format. There are some specialised forms of standard variables as follows:

  1. <?xXX>
  2. <??Variable>

All normal macros are replaced before standard macros. The "<?xXX>" form is never replaced until just before the line is to be written to the output file.

A macro's name (or parameter) can be very long and can contain nearly any character (space and end of macro replacement character are the main exceptions). Macro names should also not contain the square bracket characters (see macro indirection). You will be told if a macro name is invalid when you try to define it. The maximum length of a macro will be approximately 100 characters in OS/2 rexx and unlimited with the regina interpreter.

The name of a macro (and its parameters) are normally case insensitive, however you can make them case sensitive by using the CsReplacement option. When this option is not used all macros and parameters are converted to upper case.

You now know enough to get started with simple macros which when used along with the "#include" command are powerful facilities for reuse, not only can you reuse all or parts of a file but you can define extremely small items which are too small to put into files of their own (such as email or web addresses).

I recommend that you go on and at least the simplest macros section of the doco. After becoming familiar with ppwizard and its basic features I recommend that all of the advanced sections listed below be read, while it can be a hard slog, understanding these sections can greatly improve the quality of what you can do.

Some more advanced topics follow:

  1. Multi Line Macros
  2. Macros With Mandatory Parameters
  3. Macros With Optional Parameters
  4. Macro Parameters without values
  5. Positional Parameters (not named)

Even more advanced topics:

  1. Using Standard Definitions + Using REXX Logic
  2. Multi Line Macros With Logic
  3. Die When Unused Parms
  4. Die If Keyword Parameters used
  5. Expand All Unused Parameters
  6. Expand All Parameters As Rexx Code
  7. Macro Indirection
  8. Expand Macro Name
  9. Query, How many parameters were passed?.
  10. $$ Transformation Commands


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

[Top][Contents][Search][Prev]: Quoted Text - $The$Rest$[Next]: Simplest Macros


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Sunday November 05 2017 at 10:00am