28.3.3 Incrementing and decrementing macro variables
You can increment the value of a macro variable by 1 (one) like this:
<$$myvar++> (or just <$$myvar+>)
or decrement the value by 1 like this:
<$$myvar--> (or just <$$myvar->)
For example, to count Body paragraphs in a FrameMaker file for HTML output, incrementing the count before using it:
Body=<!-- this is <$$bodynum++ as %0.3d> -->
These settings result in a comment like the following for each instance of a Body paragraph in the HTML output:
You must include enough placeholder digits in the starting value (in this example, bp000) to accommodate the range of values you expect in the file. If you do not, the number will roll over to zero after it reaches its maximum value: in this example bp999 would increment to bp000. If the value has no digits at all at the end, the last letter is incremented instead; so a starting value of aaa increments to aab, aac, ..., aaz, aba, ..., zzz, aaa. Case is retained for the incremented (or decremented) letter.
To increment the value after use, move the incrementing code after the reference:
Body=<!-- this is <$$bodynum> --><$$bodynum++>
Numbers restart for each FrameMaker file. If you require the numbers to be unique in your Mif2Go project, you must use an individual FMfilename.ini configuration file for each FrameMaker file in your document, and include in it a [MacroVariables] section with a starting value for that file.
You can use an assignment (see §28.3.2 Assigning values to macro variables) as another form of increment, as in the following:
This form does not require reserving the maximum number of digits first.
Incrementing and decrementing using ++ or -- notation does not work with values stored as hexadecimal numbers; for those you must use an assignment to increment or decrement:
You can also display the value of an increment or decrement by adding as and a printf() format; for example:
<$$myvar = ($$myvar + 1) as %0.4d>
See §28.6.3 Displaying expression results in output for information about display formats.
You can increment a variable indirectly:
This sequence increments the value of $$other rather than the value of $$myvar. See §28.6.7 Using indirection in expressions.
> 28 Working with macros > 28.3 Using macro variables > 28.3.3 Incrementing and decrementing macro variables