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

Simplest Macros

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.

The simplest macros don't contain any logic (just text) and are used where there are many places where you wish the same information used. For example you might have an email address which you will refer to from 10 different HTML pages. If this email address changes you do not wish to look for and then change all of these occurrances. Not only would this be a real pain but you could miss one or get the new email address wrong on one (which you might never realise).

You have probably got more than one macro you wish to define (others might be web addresses for external links), it is suggested that in general the best place to keep all of them is together in one place. You could add all the macro definitions in one place in a file you create called "MACROS.IH". For example the contents of this file might be:

;--- MY EMAIL Information ---------------------------------------------------
#define MyEmailAddress           db0@bnz.com
#define EmailMeGraphic           <img src="graphics/email.jpg" border=0 width=28 height=19>

;--- Standard Graphics ------------------------------------------------------
#define ImgUpdated               <IMG SRC="graphics/updated1.gif" HSPACE=10 ALIGN=middle BORDER=0 WIDTH=52 HEIGHT=12 ALT="updated">
#define ImgNew                   <IMG SRC="graphics/new.gif"      HSPACE=10 ALIGN=middle BORDER=0 WIDTH=35 HEIGHT=20 ALT="new">
#define ImgBarbedWire            <P><CENTER><IMG SRC="graphics/barbwire.gif"></CENTER>

;--- External WEB Addresses -------------------------------------------------
#define HttpNetLabsMainPage      www.netlabs.org
#define HttpNetLabsGimpPage      www.netlabs.org/gimp/
#define HttpOs2WarpGuruMainPage  www.geocities.com/SiliconValley/Pines/7885/
#define HttpOs2WarpGuruApmPage   <$HttpOs2WarpGuruMainPage>DownloadAPM2.html

At or near the start of the source for the html page (lets call it "Intro.IT") you would add the following statement to load the macros:

;--- Load all required definitions ------------------------------------------
#include "MACROS.IH"

Later on in "INTRO.IT" you could have the following:

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

As you may guess from the above example to refer to the macro you place '<$' at the start and '>' at the end of the macro (variables) name. There is now only one place to change if your email address changes. Not only that but if you get the new address wrong it should be immediately apparent as it will be wrong in all locations! So not only have you simplified the process but you have probably improved the quality of your output as well!

There are better ways to handle what was demonstrated above but hopefully the example was a simple enough starting point. If you are still confused I suggest that you read the e-Zine! articles written by Chris Wenham (the Senior Editor of OS/2 e-Zine! chris@os2ezine.com).

Macro Context

It pays to remember that PPWIZARD really only does textual replacement (although there is a little bit of magic to detect imbedded PPWIZARD commands). It does not really know what it is inserting and why.

You need to consider the context under which your macro is intended to be used, this is true even for the very simplest definitions, for example consider:

    #define  MyName1  Dennis Bareis
    ...
    #define  MyName2  'Dennis Bareis'

The first macro could be used to place the name anywhere, HOWEVER to use in code you must put quotes around it or it must be part of a quoted string.

The second macro is less generic and so has more restrictions on where it can be used. It can be used in rexx code wherever a rexx expression can, however it might not be perfect in other contexts and could not be used in VBSCRIPT at all.

Note that $$ transformation commands are designed to make reuse in other contexts easier.


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

[Top][Contents][Search][Prev]: Macros[Next]: Multi Line 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