## 34.7 Converting autonumbers for database systems

Suppose you use FrameMaker autonumbers for headings of the style you see in the Mif2Go User's Guide; and suppose you use an automated system to populate a database with the number and text of each heading, from Mif2Go-generated HTML output. You could use macros and macro variables to capture the numerical value of each autonumber, and perhaps output the number as the name value of a tag, such as <a name=nnn>.

For example, suppose in FrameMaker you have three heading format levels, with the following autonumber scheme:

Chapter | H:<$chapnum> < =0>< =0>
Heading1 | H:<$chapnum>.<n+> < =0>
Heading2 | H:<$chapnum>.<n>.<n+>

Suppose all the headings are bold, including the autonumbers. In HTML output these heading formats might look like the following:

2 This is a chapter title

13.5 This is a second-level heading

6.2.7 This is a third-level heading

To capture each autonumber as a six-digit number, with a leading zero (as needed) for each level (for example, 060207), you could provide settings and macros such as the following:

[HTMLParaStyles]

Chapter=Split Title CodeStore CodeAfter

Heading1=Split Title CodeStore CodeAfter

Heading2=Split Title CodeStore CodeAfter

[StyleCodeStore]

; Set aside in a macro variable the code generated for each heading:

*=Stored

[ParaStyleCodeAfter]

; Parse the autonumber of each heading format; insert the resulting

; six-digit number as <a name=nnnnnn>, and then output the stored

; heading itself:

Chapter=<$ParseAnum><a name="<$ChapNum>"><$$Stored></a>

Heading1=<$ParseAnum><a name="<$Hdg1Num>"><$$Stored></a>

Heading2=<$ParseAnum><a name="<$Hdg2Num>"><$$Stored></a>

[ChapNum]

; Chapter number followed by four zeros:

<$$Chap as %0.2d>0000\

[Hdg1Num]

; Chapter number, then Heading1 number, then two zeros:

<$$Chap as %0.2d><$$Hdg1 as %0.2d>00\

[Hdg2Num]

; Chapter number, then Heading1 number, then Heading2 number:

<$$Chap as %0.2d><$$Hdg1 as %0.2d><$$Hdg2 as %0.2d>\

[ParseAnum]

; Pick through the stored code to pull out successive pieces of

; the autonumber, and put them in separate macro variables:

<$$Text = ($$Stored after "<b>")>\

<$$Anum = ($$Text before " ")>\

<$$Chap = ($$Anum before ".")>\

<$$Anum2 = ($$Anum after ".")>\

<$$Hdg1 = ($$Anum2 before ".")>\

<$$Hdg2 = ($$Anum2 after ".")>\

Trailing backslashes in the macro code prevent hard line breaks from going into the HTML output.

As each heading is processed, Mif2Go sets aside the generated HTML code in macro variable $$Stored. Mif2Go parses the stored code as follows, to extract the autonumber:

1. Skips everything in the stored code up through the <b> tag.

2. Puts in $$Anum everything between the <b> tag and the next space; this includes the whole autonumber.

3. Stores in $$Chap the characters before the first period in $$Anum.

4. Puts in $$Anum2 the characters after the first period in $$Anum.

5. Stores in $$Hdg1 the characters before the first period in $$Anum2.

6. Stores in $$Hdg2 the characters after the first period in $$Anum2.

7. Assembles each six-digit number. The %0.2d format specifier takes care of any dangling tags, and provides any needed leading zeros.

Back in the individual format settings in [ParaStyleCodeAfter], Mif2Go puts out the start of the <a> tag, and then whichever of the macro variables is needed. Finally, Mif2Go adds the original stored heading itself to the output, and closes the <a> tag.

See §28 Working with macros.

| 34.6 Supporting document review in Word |  | 34.8 Renaming output files for automated systems |