Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 34

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
on DoConfirm(prompt)
set button to button returned of (display dialog prompt ¬
return button = "Yes"
end DoConfirm
VBS
In VBScript, subroutines begin with the keyword
subroutine to return a value, you must make it a function. Functions begin with the keyword
Subroutine
The following subroutine, which is named
message Hello World.
Sub HelloWorld()
Alert "Hello World"
End Sub
To call the subroutine, you include it in a script. The following example displays a Hello World message
when a user clicks CommandButton1.
Private Sub CommandButton1_Click()
HelloWorld
End Sub
Function
The following script presents a form with one command button. When a user clicks the button, a dialog
appears with the message Are you sure? and two buttons: Yes and No. When the user clicks a button,
another dialog appears that displays the Boolean value of the clicked button: Yes = True; No = False.
'create a subroutine that calls the function DoConfirm
'and assigns it to the variable named Result
Private Sub CommandButton1_Click()
Result = DoConfirm("Are you sure?")
Alert Result
End Sub
'define the function
Function DoConfirm(prompt)
buttonPressed = Alert (prompt, vbYesNo)
DoConfirm = (buttonPressed = vbYes)
End Function
JS
In JavaScript, all subroutines are functions. The following sample script is a JavaScript version of the
VBScript sample function in the previous example.
/*create a variable and assign its value as the return value
of the function named DoConfirm*/
var theResult = DoConfirm( "Are you sure?" )
//display an alert box with the assigned value as its message
alert(theResult)
//define DoConfirm
function DoConfirm(message)
{
var result = confirm(message)
return result
buttons {"Yes", "No"} default button 1)
Photoshop CS2
and do not return a value. If you would like your
Sub
, simply displays a message box with the
HelloWorld()
Scripting basics
30
.
Function

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents