
Photoshop 7.0 Scripting Guide
17
Scripting basics
Commands and methods
2
2.7 Commands and methods
Commands (AppleScript) or methods (Visual Basic and JavaScript) are what makes things
happen in a script. The type of the object you’re working with determines how you
manipulate it.
AS
In AppleScript, use the
make
command to create new objects, the
set
command to assign
object references to variables and to change object properties, and the
get
command to
retrieve objects and their properties.
VB
In Visual Basic, use the
Add
method to create new objects, the
Set
statement to assign object
references to Visual Basic variables or properties and the assignment operator (
=
) to retrieve
and change object properties.
JS
In JavaScript, use the
add()
method to create new objects, and the assignment operator (=)
to assign both object references and variables
2.7.1 Conditional statements
Conditional statements make decisions — they give your scripts a way to evaluate something
like the blend mode of a layer or the name or date of a history state — and then act according
to the result. Most conditional statements start with the word
if
in all three scripting systems.
The following examples check the number of currently open documents. If no documents are
open, the scripts display a messages in a dialog box.
AS
tell application "Adobe Photoshop 7.0"
set documentCount to count every document
if documentCount = 0 then
display dialog "No Photoshop documents are open!"
end if
end tell