Sending Parameters To Doscript; Returning Values From Doscript - Adobe 0046100128056 - InDesign - Mac Manual

Javascript
Table of Contents

Advertisement

C
2: Scripting Features
HAPTER
Creating a script "on the fly. " Your script can create a script (as a string) during its execution, which it
can then execute using the
based on the contents of the selection or the attributes of objects the script creates.
Embedding scripts in objects. Scripts can use the
strings in the
controls its layout properties or updates its content according to certain parameters. Scripts also can
be embedded in XML elements as an attribute of the element or as the contents of an element. See
"Running Scripts at Startup" on page

Sending parameters to doScript

To send a parameter to a script executed by
DoScriptParameters tutorial script):
var myParameters = ["Hello from DoScript", "Your message here."];
var myJavaScript = "alert(\"First argument: \" + arguments[0] + \"\\rSecond argument:
\" + arguments[1]);";
app.doScript(myJavaScript, ScriptLanguage.javascript, myParameters);
if(File.fs == "Windows"){
var myVBScript = "msgbox arguments(1), vbOKOnly, \"First argument: \" &
arguments(0)";
app.doScript(myVBScript, ScriptLanguage.visualBasic, myParameters);
}
else{
var myAppleScript = "tell application \"Adobe InDesign CS5\\rdisplay
dialog(\"First argument\" & item 1 of arguments & return & \"Second argument: \"
& item 2 of arguments & return & end tell";
app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage, myParameters);
}

Returning values from doScript

The following script fragment shows how to return a value from a script executed by
example uses a JavaScript that is executed as a string, but the same method works for script files. This
example returns a single value, but you can return multiple values by returning an array (for the complete
script, refer to the DoScriptReturnValues script).
doScript
property of objects. Using this technique, an object can contain a script that
label
method. This is a great way to create a custom dialog or panel
method to run scripts that were saved as
doScript
18.
, use the following form (from the
doScript
Using the doScript Method 14
. This
doScript

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents