Returning values from do script. Adobe InCopy CS6
Reklaam
Reklaam
Scripting Features Running scripts at start-up 27
Returning values from do script
To return a value from a script executed by do script , you can use the script args (short for “script arguments”) object of the application. The following script fragment shows how to do this (for the complete script, see the DoScriptReturnValue tutorial script): tell application "Adobe InCopy CS6"
--Create a string to be run as an AppleScript.
set myAppleScript to "tell application \"Adobe InCopy CS6\"" & return set myAppleScript to myAppleScript & "tell script args" & return set myAppleScript to myAppleScript & "set value name \"ScriptArgumentA\" value
\"This is the first AppleScript script argument value.\"" & return set myAppleScript to myAppleScript & "set value name \"ScriptArgumentB\" value
\"This is the second AppleScript script argument value.\"" & return set myAppleScript to myAppleScript & "end tell" & return set myAppleScript to myAppleScript & "end tell"
--Run the AppleScript string.
do script myAppleScript language applescript language
--Retrieve the script argument values set by the script.
tell script args set myScriptArgumentA to get value name "ScriptArgumentA" set myScriptArgumentB to get value name "ScriptArgumentB" end tell
--Display the script argument values in a dialog box.
display dialog "ScriptArgumentA: " & myScriptArgumentA & return & "ScriptArgumentB:
" & myScriptArgumentB
--Create a string to be run as a JavaScript.
set myJavaScript to "app.scriptArgs.setValue(\"ScriptArgumentA\", \"This is the first JavaScript script argument value.\");" & return set myJavaScript to myJavaScript & "app.scriptArgs.setValue(\"ScriptArgumentB\",
\"This is the second JavaScript script argument value.\");" & return
--Run the JavaScript string.
do script myJavaScript language javascript
--Retrieve the script argument values set by the script.
tell script args set myScriptArgumentA to get value name "ScriptArgumentA" set myScriptArgumentB to get value name "ScriptArgumentB" end tell
--Display the script argument values in a dialog box.
display dialog "ScriptArgumentA: " & myScriptArgumentA & return & "ScriptArgumentB:
" & myScriptArgumentB end tell
Running scripts at start-up
To run a script when InCopy starts, put the script in the Startup Scripts folder in the Scripts folder (for more
information, see “Installing scripts” on page 11
).
Laadi alla
Reklaam