Adobe 23101335 - Photoshop - PC Manual page 15

Scripting guide
Hide thumbs Also See for 23101335 - Photoshop - PC:
Table of Contents

Advertisement

2.5.2 Using variables to store references
Variables can also be used to store references to objects. In AppleScript, a reference is returned
when you create a new object in an Photoshop document as shown below:
set thisLayer to make new art layer in current document
Or you can fill the variable with a reference to an existing object:
set thisLayer to art layer 1 of current document
Visual Basic works similarly, however, there is an important distinction to note. If you are
assigning an object reference to a variable you must use the Set command. For example, to
assign a variable as you create a layer, use Set :
Set thisLayer = appRef.Photoshop.ActiveDocument.ArtLayers(1)
or in reference to an existing layer, since it is also an object reference, use Set :
Set thisLayer = appRef.Photoshop.ActiveDocument.ArtLayers(1)
If you are trying to assign a value to a variable in Visual Basic that is not an object reference,
do not use Set . Use Visual Basic's assignment operator, the equals sign:
thisNumber = 12
JavaScript looks similar to Visual Basic. To assign a reference to an object, you would write:
var docRef = activeDocument;
and to assign a value use the following:
var thisNumber = 12
2.5.3 Naming variables
It's a good idea to use descriptive names for your variables—something like firstPage or
corporateLogo , rather than 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.
Variable names must be a single word, but you can use internal capitalization (such as
myFirstPage ) or underscore characters ( my_first_page ) to create more readable names.
Variable names cannot begin with a number, and they can't contain punctuation or quotation
marks.
Photoshop 7.0 Scripting Guide
Scripting basics
2
Variables
15

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop 7.0

Table of Contents