Omni Systems, Inc. Mif2Go User's Guide, Version 55

<< Prev | Next >>

> 28 Working with macros > 28.3 Using macro variables > 28.3.1 Creating and invoking macro variables > 28.3.1.3 Invoking a macro variable

#### 28.3.1.3 Invoking a macro variable

You invoke a macro variable like this:

<$$varname>

Or like this:

<$$varname as display-format>

where display-format is a C-language style printf() format. See §28.6.3 Displaying expression results in output.

You do not need the enclosing angle brackets when you use a macro variable inside a macro; for example, in an assignment such as <$$myvar = ($$othervar + 2)>.

An example

Suppose you want to use a macro that includes the following:

• an image, but with a different src attribute each time

• a heading, but with different text each time.

Rather than have two almost identical macros, you can use a macro variable for the src attribute and another for the heading, then set their values appropriately for each use.

You could define the macro like this:

[TopStory]

<img src="<$$Pic>" alt="Today’s top story" /><h2><$$Head></h2>

Call it like this one day:

<$$Pic=lead000201.jpg><$$Head=No Survivors in Crash><$TopStory>

and like this the next day:

<$$Pic=lead000202.jpg><$$Head=MS Embraces Linux><$TopStory>