Adobe 23101335 Scripting Guide - Page 49
Passing arguments to JavaScript, For Visual Basic, use either the Application's
UPC - 718659152833
View all Adobe 23101335 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 49 highlights
Scripting Photoshop 3 Executing JavaScripts from AS or VB For Visual Basic, use either the Application's DoJavaScript or DoJavaScriptFile method. DoJavaScript takes a string, which is the JavaScript code to execute. DoJavaScriptFile opens a file that contains the JavaScript code. An example is below: AS: set scriptFile to "myscript" as alias do javascript scriptFile VB: Dim appRef As Photoshop.Application Set appRef = CreateObject("Photoshop.Application") appRef.DoJavaScriptFile ("D:\\Scripts\\MosaicTiles.js") 3.6.1 Passing arguments to JavaScript You can pass arguments to JavaScript from either AppleScript or Visual Basic by using the with arguments (Arguments) parameter. The parameter takes an array for you to pass any values. For example, save the following JavaScript in a file somewhere on your machine: alert( "You passed " + arguments.length + " arguments" ); for ( i = 0; i < arguments.length; ++i ) { alert( arguments[i].toString() ) } To pass arguments from AppleScript try this: tell application "Adobe Photoshop 7.0" make new document do javascript (alias ) ¬ with arguments {1, "test text", (file ),¬ current document} 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", _ Array(1, "text text", appRef.ActiveDocument) When running JavaScript from AppleScript or Visual Basic you can also control the debugging state. To do this you use the show debugger (ExecutionMode) argument. The values of this argument include: Photoshop 7.0 Scripting Guide 49