Adobe 23101335 Scripting Guide - Page 17

Commands and methods, 2.7.1 Conditional statements

Page 17 highlights

Scripting basics 2 Commands and methods 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 Photoshop 7.0 Scripting Guide 17

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91

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