2018.2

Table Of Contents
l
Control Scripts run before all other scripts. When a template consists of several contexts,
and these contexts are combined in the output - for example, when an Email is generated
with the Print context as attachment - all scripts run once for each context, but Control
Scripts always go first.
l
Control Scripts do not touch the content - meaning, the text flow - of the sections.
They don't have a selector, like the other scripts do. A selector selects parts of the content
of a section and stores them in the results object, so that they can be modified in the
script. As Control Scripts don't have a selector, the results object can't be used there.
Similarly, the query() function, which is used to select content from within a script, is
unavailable in a Control Script.
Adding a Control Script
To add a Control Script:
1.
On the Scripts pane at the bottom left, click the black triangle on the New button and click
Control Script. A new script appears in the list.
2. Double-click the new script to open it. The script editor appears.
3. Change the name of the script so that it reflects what the script does.
Note
Scripts can only have the same name when they are not in the same folder.
4. Write the script; see the "Control Script API" on page1162. If you are not familiar with
scripting, also see "Writing your own scripts" on page722.
Tip
New Control Scripts added to the template contain code to continue the page
numbering over all print sections, and two examples: one to select different sections
of a Print context for email and print output, and one to select a Web section.
Page 752