2019.1

Table Of Contents
Some knowledge of JavaScript is needed to edit Control Scripts, just as for any other self-made
scripts; see "Writing your own scripts" on page798. Some functionality is provided as a
Scripting Wizard, for example Conditional Print Sections.
This topic explains how to add a Control Script and it gives an overview of what Control Scripts
can do. It will also tell you where you will find information about each feature, including
examples.
The basics of script-writing in the Designer are explained in the following topic: "Writing your
own scripts" on page798.
What Control Scripts are
Control Scripts are a special kind of Designer script. They can manipulate the way output is
generated from a template. They allow you, for example, to change the page numbering in Print
output, to split one generated Print document into multiple Email attachments, or to set a Print
section's background dynamically. (These are only a few examples; for more uses of Control
Scripts see "What to use a Control Script for" on the facing page.)
Control Scripts differ from Standard scripts in two ways:
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.
Page 828