Adobe 23101764 - Photoshop CS - PC Manual page 67

Scripting guide
Hide thumbs Also See for 23101764 - Photoshop CS - PC:
Table of Contents

Advertisement

3.7.1 Passing arguments to JavaScript
You can also pass arguments to JavaScript from either AppleScript or Visual Basic by using
the with arguments (Arguments) parameter. The parameter takes an array to pass any
values.
For example, save the following JavaScript to a file on your machine:
alert( "You passed " + arguments.length + " arguments" );
for ( i = 0; i < arguments.length; ++i )
{
}
To pass arguments from AppleScript try this:
tell application "Adobe Photoshop CS"
end tell
To do the same thing in VB, write:
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
appRef.DoJavaScriptFile "C:\scripts-temp\test.js", _
When running JavaScript from AppleScript or Visual Basic you can also control the debugging
state. To do this, use the show debugger (ExecutionMode) argument. The values of this
argument include:
• never (NeverShowDebugger): This option will disable debugging from the JavaScript.
Any error that occurs in the JavaScript will result in a JavaScript exception being thrown.
Note that you can catch JavaScript exceptions in your script; see the JavaScript Reference
Guide for more information on how to handle JavaScript exceptions. When you use this
option the JavaScript command "debugger();" will be ignored.
• on runtime error (DebuggerOnError): This option will automatically stop the
execution of your JavaScript when a runtime error occurs and show the JavaScript
debugger. When you use this option the JavaScript command "debugger();" will stop the
JavaScript and display the JavaScript debugger.
• before running (BeforeRunning): This option will show the JavaScript debugger at
the beginning of your JavaScript. When you use this option the JavaScript command
"debugger();" will stop the JavaScript and display the JavaScript debugger.
Photoshop CS Scripting Guide
alert( arguments[i].toString() )
make new document
do javascript (alias <a path to the JavaScript shown above>) ¬
with arguments {1, "test text", (file <a path to a file>),¬
current document}
Array(1, "text text", appRef.ActiveDocument)
Scripting Photoshop
Executing JavaScripts from AS or VB
3
63

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs

Table of Contents