Using the TOC-ENTRY Command

Use TOC-ENTRY to place an entry into the table of contents and take the mandatory TEXT argument, which specifies the text to be placed in the table of contents. Legal text includes text literals, variables, and columns. To include levels in a table of contents, use the LEVEL argument, which specifies the level at which to place the text. If you do not specify this argument, the value of the previous level is used.

If you are writing programs that generate multiple reports, you can:

  • Use the FOR-REPORTS argument of the DECLARE-TOC command to identify the reports to which the DECLARE-TOC command applies.

  • Use the TOC argument of the DECLARE-REPORT command to specify the name of the table of contents for the report.

A program can have multiple DECLARE-TOC statements and multiple DECLARE-REPORT statements. However, you must include the FOR-TOCS argument in the DECLARE-TOC statements or the TOC argument in the DECLARE-REPORT statements.

To specify the name of the table of contents for a given report by using the TOC argument of the DECLARE-REPORT command, include code in the SETUP section of the program. For example:

 begin-setup
      declare-report
          toc = toc_name
      end-declare
     .
     .
     .
end-setup

Earlier, we modified the sample program ex7a.sqr to use the DECLARE-TOC and TOC-ENTRY commands. Then, we generated HTML output from the modified program by using the -PRINTER:EH and -PRINTER:HT command-line flags. In HTML, the table of contents file is a linked point of navigation for the online report.

However, you may also want to generate output files for printing hard-copy reports. The table of contents features can also perform this task. To test this assertion, run the modified version of the sample program ex7a.sqr and print it from an .lis file (or use -PRINTER:WP in Microsoft Windows). The table of contents output contains the traditional dot leaders and necessary page numbers relating to a hard-copy report.

See Using the DECLARE-PRINTER Command and Understanding the Sample Program for Printing Mailing Labels.