![]() | ![]() | ![]() | ![]() | ![]() |
Multi Line Macros With Logic |
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.
In this example we add some conditional inclusion where the same macro can generate different text based on the environment or parameters that are passed to it. In the following macro the size of the image file is calculated unless a value was passed to it.
You might create a macros as follows to display some photos in a table:
;--- Photo macro will either use passed size or work out correct size for you --- #define Photo \ #evaluate+ LocalFileName ^"..\graphics\{$Image}"^ \ #DependsOn INPUT "<$LocalFileName>" \ <TR> \ #if "{$Size=''}" <> "" \ #define+ TmpSize {$Size=''} ;;User supplied size \ #elseif \ #evaluate+ TmpSize ^GetImageHeightWidth("<$LocalFileName>")^ \ #endif \ <TD ALIGN=CENTER> \ <IMG SRC="graphics/clear1x1.gif" WIDTH=1 HEIGHT=1 VSPACE=20> \ {$Title}<BR><BR> \ <IMG SRC="graphics/{$Image}" BORDER=0 <$TmpSize> ALT="{$Title}"> \ <IMG SRC="graphics/clear1x1.gif" WIDTH=1 HEIGHT=1 VSPACE=20> \ </TR>
It is then a simple matter to create format and add new photos as follows (note that the image size is automatically calculated):
;--- Create table of photos -------------------------------------------- <BR><CENTER><TABLE COLS=1 BORDER=10 CELLSPACING=10> <TR> <TH ALIGN=CENTER>Pictures </TR> ;--- Include all my photos ------------------------------------------ <$Photo Image="lazy.jpg" Title="Watching TV"> <$Photo Image="carback.jpg" Title="New Car (Back Left)"> </TABLE></CENTER>
![]() | ![]() | ![]() | ![]() | ![]() |