Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting basics 18
script a year after you write it, such as
x
or
c
. You can also give your variable names a standard prefix so
that they’ll stand out from the objects, commands, and keywords of your scripting system. For example,
you could use the prefix “doc” at the beginning of any variables that contain
Document
objects, or “layer”
to identify variables that contain
Art Layer
objects.
●
Variable names must be a single word (no spaces). Many people use internal capitalization (such as
myFirstPage
) or underscore characters (
my_first_page
) to create more readable names.
●
Variable names cannot begin with a number or contain punctuation or quotation marks.
You can use underscore characters ( _ ), but not as the first character in the name.
●
Variable names in JavaScript and VBScript are case sensitive.
thisString
is not the same as
thisstring
or
ThisString
.
Variable names in AppleScript are not case sensitive.
Using Object Properties
Properties describe an object. For example, a
Document
object’s height and width properties describe the
document’s size.
To access and modify a property of an object, you name the object and then name the property. The
specific syntax varies by language. The following examples use the kind property of the
ArtLayer
object
to make the layer a text layer.
AS
You can specify properties using
with properties
at the end of the statement and enclosing the
properties in brackets ({ }). Within the brackets, you name the property and then type a colon (:) and the
property definition after the colon, as in the following sample.
make new art layer with properties {kind:text}
VBS
In VBScript, you use an object’s property by naming the object, then typing a period (.), and then typing
the property. Use the equals sign (=) to set the property value.
Set layerRef toArtLayers.Add
layerRef.Kind = 2
Note:
The
Kind
property value, 2, is a constant value. VBScript uses the enumerated constant values
rather than the text version of the value. To find constant values, refer to the “Constants’ chapter in
the appropriate scripting reference. For more information, see
‘Understanding and Finding
Constants’ on page 19
.
JS
In JavaScript, you name the object, type a period (.), and then name the property, using the equals sign (=)
to set the property value.
var layerRef = artLayers.add()
layerRef.kind = LayerKind.TEXT
Note:
The
kind
property in JavaScript uses a
constant
value indicated by the upper case formatting. In
JavaScript, you must use constant values exactly as they appear in the scripting language reference.
To find constant values, refer to the “Constants’ chapter in the appropriate scripting reference. For
more information, see
‘Understanding and Finding Constants’ on page 19
.