Tutorial 17 - Using multiple Print Templates
The page formatting mechanism of Scribe is based on Print Templates that control all aspects of laying out the printed content of every page. Multiple Print Templates can be used within the same report, either directly as multiple occurrences of individual Print components in a given flowchart, or indirectly through the use of black-boxed Report Procedures called from within larger (outer) Procedures.
The ability to use multiple Print Templates of different layouts within one report means that the reports can be composed of dissimilar pages, each set of pages being laid out according to its nature. This is a powerful feature, but its use requires careful consideration of possible side effects that interaction of different Print Templates may cause. This Tutorial is intended to explain these side effects and show the way to control them.
We will construct a report that prints all Order info for the selected Customer, and then - in subsequent sections - prints the detailed contents of each Order. In Tutorial 4 and Tutorial 6 we have already constructed two separate reports: Customer and Order. These reports ran individually, even though they were later linked through a drill-down mechanism; now we will combine them into one composite procedure.
The new Report Procedure is shown below; it incorporates all of the original Customer procedure, but it also captures the Order IDs and stores them in an Array component. In the tail-end of the flowchart, another loop extracts the Order ID numbers from the Array and calls the Order report on each Order ID.
(Click on the image to enlarge)
Save the report as Query/CustomerOrderCombo, and run it for Customer VINET. We should get the following report pages:
Something is wrong with the second (and all subsequent) pages of the report. The pages begin with the Header of Customers Print Template, used in the first part of the Report Procedure, and the Segment Inspector for this template's Header is set to print itself when the new page begins. Once the Customers template becomes active (after the first call to it in the Report Procedure), it watches for the page breaks, and prints its Header portion every time the page break happens (in the figure above, this is the area of the page highlighted with yellow color).
This is an unwanted side effect of the Print Template's ability to automate the process of laying out the report page. Somehow we need to tell the Print component enclosing the Customers template to stop watching the page breaks and go away until further notice (or, as it happens in this particular case, to just go and never come back). Scribe provides the Terminator component to do just that.
Drag the Terminator component into the Report Procedure and drop it as shown in the following figure:
The Terminator component is controlled by the Inspector, where the Print component to be terminated is set:

The Inspector shows the list of all Print components used in the procedure; in our case it shows only Query/Customers component, as the other one used in this report (Query/OrderDetail) is not actually part of the flowchart, but is enclosed into a "black box" of the Order report. The Report Procedure with the Terminator component in it is shown below:
(Click on the image to enlarge)
If we run this modified report now, the second page of the report comes as follows:
The Terminator component can also be used for controlling the printing of Footer segments of Print Templates (not used in this Tutorial).
Termination of Print components with the Terminator component resets the internal state of the Print component, so that if and when it is executed again, its behavior is identical to that of the component that has never been executed prior to the call.
You can read more on the Print component's behavior in The Life Cycle of Print Templates.
![]()