Using Conditional Statements - Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide

Using Conditional Statements

Conditional statements give your scripts a way to evaluate something and then act according to the result.
For example, you may want your script to detect the blend mode of a layer or the name or date of a history
state.
Most conditional statements contain the word
The following examples check whether any documents are open; if no documents are open, the scripts
display a dialog box that contains the message "No Photoshop CS2 documents are open!". If one or more
documents are open, then no dialog is displayed.
AS
tell application "Adobe Photoshop CS2"
(*create a variable named docCount to contain the document count,
then use the count command to get the value*)
set docCount to count every document
if docCount = 0 then
end if
end tell
VBS
'create a variable named docCount for the document count, open Photoshop
Dim docCount As long
Dim appRef As New Photoshop CS2.Application
'use the count property of the Documents collection object to count the number of
open documents
docCount = appRef.Documents.Count
If docCount = 0 Then
End If
JS
//create a variable named docCount,
//then get its value using
//the length property of the documents (collection) object*/
var docCount = documents.length
if (docCount == 0)
{
alert("No Photoshop CS2 documents are open!")
}
Loops
Loops are control structures that repeat a process until the script achieves a specific goal, status, or
condition.
Simple Loops
The simplest loops repeat a series of script operations a set number of times. Although you'll find more
substantial uses for loops, the following scripts use a variable named
display a dialog box that contains the number 1, then display another dialog that contains the number 2,
and then display a third dialog that contains 3.
display dialog "No Photoshop CS2 documents are open!"
Alert "No Photoshop CS2 documents are open!"
Photoshop CS2
, or the words
if
and
.
if
then
to demonstrate how to
counter
Scripting basics
26

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents