![]() | ![]() | ![]() | ![]() | ![]() |
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@anz.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).
![]() | ![]() | ![]() | ![]() | ![]() |