Adobe 23101764 Scripting Guide - Page 26

Operators, 8 Commands and methods

Page 26 highlights

Scripting basics 2 Operators 2.7 Operators Operators perform calculations (addition, subtraction, multiplication, and division) on variables or values and return a result. For example: docWidth/2 would return a value equal to half of the content of the variable docWidth. So if docWidth contained the number 20.5, the value returned would be 10.25. You can also use operators to perform comparisons (equal to, not equal to, greater than, or less than, etc.). Some operators differ between AppleScript, Visual Basic and JavaScript. Consult your scripting language for operators that may be unique to your OS. AppleScript and Visual Basic use the ampersand (&) as the concatenation operator to join two strings. "Pride " & "and Prejudice." would return the string "Pride and Prejudice." JavaScript uses the "+" operator to concatenate strings. "Pride" + " and Prejudice" would return the string "Pride and Prejudice." 2.8 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. Photoshop CS Scripting Guide 22

  • 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
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
22
Scripting basics
Operators
2
2.7 Operators
Operators perform calculations (addition, subtraction, multiplication, and division) on
variables or values and return a result. For example:
docWidth/2
would return a value equal to half of the content of the variable
docWidth
. So if
docWidth
contained the number
20.5,
the value returned would be
10.25
.
You can also use operators to perform comparisons (equal to, not equal to, greater than, or less
than, etc.). Some operators differ between AppleScript, Visual Basic and JavaScript. Consult
your scripting language for operators that may be unique to your OS.
AppleScript and Visual Basic use the ampersand (&) as the concatenation operator to join two
strings.
"Pride " & "and Prejudice."
would return the string “Pride and Prejudice.”
JavaScript uses the “+” operator to concatenate strings.
"Pride" + " and Prejudice"
would return the string “Pride and Prejudice.”
2.8 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.