Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 20

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
To assign a value to a variable, you use the equals sign (=), as follows:
thisNumber = 10
thisString = "Hello, World"
Note:
Remember to enclose string values in straight, double quotes ("").
Another rule of thumb for proper scripting in VBScript is to declare all of your variables somewhere near
the beginning of the script. That way you can easily see which variables are in use without having to search
throughout the script for them.
The VBScript tool
statement. It also helps you avoid situations in which you try to use a misspelled variable name or an
undeclared variable. You use
code sample:
Option Explicit
Dim thisNumber
Dim thisString
thisNumber = 10
thisString = "Hello, World"
Assigning an Object Reference as a Value
You assign an object reference as the value of a variable, use the
The following example uses
object, and then assign the new
Layer
Dim thisLayer
Set thisLayer = AppRef.Documents(0).ArtLayers.Add
The next example uses
object added to the script) as the value of
Dim thisLayer
Set thisLayer =AppRef.Documents(0).ArtLayers(2)
Using the Variable in a Script Statement
When you use variables in your script to represent values, you use only the variable name without the
or
keyword. The following example rotates the selected section of the
Set
represented by the variable
thisLayer.Selection.Rotate(45)
VBScript Value Types
You can use the following types of values for variables in VBScript.
Note:
For now, don't worry about the value types you don't understand.
Value Type
Boolean
Empty
Error
Null
Number
Photoshop CS2
forces you to declare all variables before you use them in a script
Option Explicit
Option Explicit
and the
Set
Add
Art Layer
to assign an existing
Set
thisLayer
What It Is
Logical true or false
The variable holds no data
Stores an error number
The variable holds no valid
value (Usually used to test
an error condition)
Any number not inside
double quotes
before you declare any variables, as in the following
method to create the variable
object as the value of
object (in this case, the third
Art Layer
:
thisLayer
by 45 degrees:
Example
true
false
myVar = Empty
null
3.7
2000
command as well as the equal sign.
Set
, create a new
thisLayer
thisLayer
Art Layer
Scripting basics
16
Art
:
Art Layer
Dim
object

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents