Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting basics 33
command. The following sample requests the display of the variables
myVariable
and
otherVariable
.
log {myVariable, otherVariable}
➤
To view results in the Results window rather than the Event Log:
1. Choose
Controls > Show Result
.
Note:
Third-party editors offer additional debugging features.
VBScript Debugging
The Windows Script Host cancels your script and displays an error message when you try to run a VBScript
that contains faulty syntax or other code errors. The error message names the script and indicates the line
in and character position in which it believes the error is located, along with an error description. You can
use this information as a guideline. However, often, the syntax error is in the line preceding the error
description in the message.
You can trace the execution of your script elements when the script is running by adding MsgBox
commands. A MsgBox command stops your script at point where the command has been inserted and
displays a dialog with the message you included in the command. The syntax for a message box that
displays the message
My Message
is:
MsgBox (“My Message”)
Check your VBScript documentation for more information. Windows Scripting Host also provides
debugging information.
JavaScript Debugging
JavaScript debugging is described in detail in the
Adobe Photoshop CS2 JavaScript Scripting Reference
on
the Photoshop installation CD. Please refer to that document for further information.
Error Handling
Imagine that you’ve written a script that formats the current text selection. What should the script do if the
current selection turns out not to be text at all, but a path item? You can add
error handling
code to your
script to respond to conditions other than those you expect it to encounter.
The following example shows how you can stop a script from executing when a specific file cannot be
found. This example stores a reference to the document named
MyDocument
in a variable named
docRef
. If a document named
MyDocument
does not exist in the current document, the script displays a
message.
AS
—Store a reference to the document with the name "My Document"
—If “My Document” does not exist, display an error message
tell application "Adobe Photoshop CS2"
try
set docRef to document "My Document"
display dialog "Found 'My Document' "
on error
display dialog "Couldn't locate document 'My Document'"
end try
end tell
Содержание PHOTOSHOP CS 2.0 - SCRIPTING GUIDE
Страница 1: ...bbc Adobe Photoshop cs 2 Scripting Guide ...