<$IFexpression>...if part... [<$ELSE>...optional else part... ]</$IF>
A good example for the usage of conditional conversion inside a macro is
the <WEBPAGE> macro used to create the documentation for hsc.
It also shows how to create a navigation bar with optional references to a next and previous page.
<**************************************
* WEBPAGE_NAVIGATION *
* this is a local macro that is *
* allowed to be used from inside of *
* <WEBPAGE> (see below) *
* it inserts a navigation bar at *
* current position *
***************************************>
<$macro WEBPAGE_NAVIGATION /MBI="WEBPAGE">
<** main button **>
<$if (NOT SET NoMain)>
<A HREF=":index.html"><IMG SRC=":image/main.gif" ALT="Main" ALIGN="middle"></A>
<$else>
<IMG SRC=":image/nomain.gif" ALT="----" ALIGN="middle">
</$if>
<** insert "index" button **>
<$if (NOT SET NoIndex)>
<A HREF=":index.html"><IMG SRC=":image/index.gif" ALT="Index" ALIGN="middle"></A>
<$else>
<IMG SRC=":image/noindex.gif" ALT="-----" ALIGN="middle">
</$if>
<** copyright button **>
<$if (NOT SET NoCopy)>
<A HREF=":copy.html"><IMG SRC=":image/copy.gif" ALT="Copyright" ALIGN="middle"></A>
<$else>
<IMG SRC=":image/nocopy.gif" ALT="---------" ALIGN="middle">
</$if>
<** insert "back" (up) button **>
<$if (SET Back)>
<A HREF=(Back)><IMG SRC=":image/back.gif" ALT="Up" ALIGN="middle"></A>
<$else>
<IMG SRC=":image/noback.gif" ALT="--" ALIGN="middle">
</$if>
<** insert "previos" button **>
<$if (SET Prev)>
<A HREF=(Prev)><IMG SRC=":image/prev.gif" ALT="Previous" ALIGN="middle"></A>
<$else>
<IMG SRC=":image/noprev.gif" ALT="--------" ALIGN="middle">
</$if>
<** insert "next" button **>
<$if (SET Next)>
<A HREF=(Next)><IMG SRC=":image/next.gif" ALT="Next" ALIGN="middle"></A>
<$else>
<IMG SRC=":image/nonext.gif" ALT="----" ALIGN="middle">
</$if>
</$macro>
<*****************************
* WEBPAGE *
******************************>
<$macro WEBPAGE Title:string/r
Chapter:string=""
Next:uri prev:uri
Back:uri=":index.html"
NoIndex:bool="true"
NoCopy:bool
NoMain:bool>
<HTML>
<HEAD>
<TITLE><$insert TEXT=(Chapter)><$insert TEXT=(Title)></TITLE>
<LINK REV="owns" TITLE="Thomas Aglassinger" HREF="mailto:agi@giga.or.at">
<$if (SET NoMain)>
<LINK REL="Home" HREF=":hsc.html">
</$if>
<LINK REL="Copyright" HREF=":copy.html">
<$if (SET prev)>
<LINK REL="Previous" HREF=(Prev)>
</$if>
<$if (SET next)>
<LINK REL="Next" HREF=(Next)>
</$if>
</HEAD>
<BODY>
<*<IMG SRC=":image/head.gif" ALT="hsc"><BR>*>
<Webpage_Navigation>
<HR><H1><$insert TEXT=(Title)></H1>
</$macro>
<*****************************
* /WEBPAGE *
* foot line (sigh & date) *
*****************************>
<$macro /WEBPAGE>
<HR>
<ADDRESS>
Thomas Aglassinger
(<A HREF="mailto:agi@giga.or.at">agi@giga.or.at</A>),
<$insert TIME FORMAT="%d-%b-%Y">
</ADDRESS>
</BODY></HTML>
</$macro>
<$IF ..> is nestable.
You can't compare hsc's <$IF ..> to #if
of the C-preprocessor. The main difference is that you can use <$IF ..>
inside macros and that expressions are recalculated for every new
call of the macro.