EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Controlling Undo with Doscript; Working with Script Labels

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 2: Scripting Features Controlling Undo with doScript 16
//Create a string to be run as a AppleScript.
p1 = "tell application \"Adobe InDesign CS5\"\r";
p2 = "tell script args" +"\r";
p3 = "set value name\"" + nameA +"\" value ";
p4 = "\"This is the firest AppleScript script argument value.\"" +"\r";
p5 = "set value name\"" + nameB +"\" value ";
p6 = "\"This is the second AppleScript script argument value.\"" +"\r";
p7 = "end tell" + "\r"
p8 = "end tell" + "\r"
var myAppleScript = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;
app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage);
}
var myScriptArgumentA = app.scriptArgs.getValue(nameA);
var myScriptArgumentB = app.scriptArgs.getValue(nameB);
alert(nAc + myScriptArgumentA + nBc + myScriptArgumentB);
Controlling Undo with doScript
InDesign gives you the ability to undo almost every action, but this comes at a price: for almost every
action you make, InDesign writes to disk. For normal work you using the tools presented by the user
interface, this does not present any problem. For scripts, which can perform thousands of actions in the
time a human being can blink, the constant disk access can be a serious drag on performance.
The
doScript method offers a way around this performance bottleneck by providing two parameters that
control the way that scripts are executed relative to InDesigns Undo behavior. These parameters are
shown in the following examples:
//Given a script "myJavaScript" and an array of parameters "myParameters"...
app.doScript(myJavaScript, ScriptLanguage.javascript, myParameters,
UndoModes.fastEntireScript, "Script Action");
//UndoModes can be:
//UndoModes.autoUnto: Add no events to the Undo queue.
//UndoModes.entireScript: Put a single event in the Undo queue.
//UndoModes.fastEntireScript: Put a single event in the Undo queue.
//UndoModes.scriptRequest: Undo each script action as a separate event.
//The last parameter is the text that appears in the Undo menu item.
Working with Script Labels
Many objects in InDesign scripting have a label property, including page items (rectangles, ovals, groups,
polygons, text frames, and graphic lines), table cells, documents, stories, and pages. This property can
store a very large amount of text.
The label of page items can be viewed, entered, or edited using the Script Label panel (choose Window >
Utilities > Script Label to display this panel), shown below. You also can add a label to an object using
scripting, and you can read the script label via scripting. For many objects, like stories, pages, and
paragraph styles, you cannot set or view the label using the Script Label panel.

Table of Contents

Related product manuals