PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Using Standard Definitions + Using REXX Logic[Next]: Macro Indirection
\ -> Macros -> Multi Line Macros With Logic

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>        \

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 --------------------------------------------
       <TH ALIGN=CENTER>Pictures

       ;--- Include all my photos ------------------------------------------
       <$Photo Image="lazy.jpg"     Title="Watching TV">
       <$Photo Image="carback.jpg"  Title="New Car (Back Left)">

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

[Top][Contents][Search][Prev]: Using Standard Definitions + Using REXX Logic[Next]: Macro Indirection

My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Saturday May 28 2022 at 2:55pm