Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 37

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
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:
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
. If a document named
docRef
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
on error
end try
end tell
command. The following sample requests the display of the variables
.
otherVariable
log {myVariable, otherVariable}
MsgBox ("My Message")
MyDocument
set docRef to document "My Document"
display dialog "Found 'My Document' "
display dialog "Couldn't locate document 'My Document'"
Photoshop CS2
does not exist in the current document, the script displays a
myVariable
in a variable named
MyDocument
Scripting basics
33
and

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents