Omni Systems, Inc.

  

Mif2Go User's Guide, Version 55

  

Valid HTML 4.01!

 

Made with Mif2Go

28 Working with macros > 28.4 Using multiple-value list variables > 28.4.4 Using macros to process lists


28.4.4 Using macros to process lists

Suppose you want to generate a different set of sidebar navigation links for each major section of a Web site, where each section is in a single FrameMaker file that Mif2Go splits into named pages (see §18 Splitting and extracting files). For each page, the sidebar item that names that page should not be a link, because a live link to the current page confuses people.

You need a slightly different list of sidebar items on every HTML page, to avoid a same-page link. But the logic is always the same, as are the names of files and the titles to be displayed. What is needed is a macro that takes into account which item should not be linked.

Your configuration file could include a pair of lists, one with file names and the other with matching sidebar titles, like this:

[FM_File]

1 = homepage

2 = descript

3 = operate

4 = testimonial

5 = demo

6 = order

[SideTitle]

1 = Widgets

2 = What a Widget Does

3 = How to Use a Widget

4 = What Users Say About Widgets

5 = Get a Demo Widget

6 = Order Widgets On Line

You could process the two lists with this macro:

[Sidebar]

<$$val=2><$$maxval=6>\

<$_while ($$val <= $$maxval)>\

  <$_if ($$_currbase is $$FM_File[$$val])>\

    <p class="SidebarTxt"><$$SideTitle[$$val]></p>\

    <$_else>\

    <p class="SidebarTxt"><a class="SidebarLnk"\

    href="<$$FM_File[$$val]>.htm"><$$SideTitle[$$val]></a></p>\

    <$_endif>

  <$$val++>

  <$_endwhile>



28 Working with macros > 28.4 Using multiple-value list variables > 28.4.4 Using macros to process lists