Getting the Current Script. Adobe InDesign CS6
Werbung
Werbung
C HAPTER 2: Scripting Features Getting the Current Script 12
Property user interaction level version
Description
This property controls the alerts and dialogs InDesign presents to the user.
When you set this property to never interact
, InDesign does not display any alerts or dialogs. Set it to interact with alerts
to enable alerts but disable dialogs. Set it to interact with all
to restore the normal display of alerts and dialogs. The ability to turn off alert displays is very useful when you are opening documents via script; often, InDesign displays an alert for missing fonts or linked graphics files. To avoid this alert, set the user-interaction level to never interact
before opening the document, then restore user interaction (set the property to interact with all
) before completing script execution.
The version of the scripting environment in use. For more information, see
“Script Versioning” on page 12
. Note this property is not the same as the version of the application.
Getting the Current Script
You can get a reference to the current script using the active script
property of the application object.
You can use this property to help you locate files and folders relative to the script, as shown in the following example (from the ActiveScript tutorial script): tell application "Adobe InDesign CS6" set myScript to active script display dialog ("The current script is: " & myScript) tell application "Finder" set myFile to file myScript set myParentFolder to container of myFile end tell display dialog ("The folder containing the active script is: " & myParentFolder) end tell
When you debug scripts using a script editor, the active script
property returns an error. Only scripts run from the Scripts palette appear in the active script
property.
Script Versioning
InDesign can run scripts using earlier versions of the InDesign scripting object model. To run an older script in a newer version of InDesign, you must consider the following:
Targeting — Scripts must be targeted to the version of InDesign in which they are being run (i.e., the
Compilation — This involves mapping the names in the script to the underlying script IDs, which are what InDesign understands. The mechanics of compilation are language specific as described in
.
Interpretation — This involves matching the IDs to the appropriate request handler within InDesign so that InDesign correctly interprets a script written for an earlier version of the scripting object model.
To do this, either explicitly set the application’s script preferences to the old object model within the
Herunterladen
Werbung