Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting basics 30
on DoConfirm(prompt)
set button to button returned of (display dialog prompt ¬
buttons {"Yes", "No"} default button 1)
return button = "Yes"
end DoConfirm
VBS
In VBScript, subroutines begin with the keyword
Sub
and do not return a value. If you would like your
subroutine to return a value, you must make it a function. Functions begin with the keyword
Function
.
Subroutine
The following subroutine, which is named
HelloWorld()
, simply displays a message box with the
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
Содержание PHOTOSHOP CS 2.0 - SCRIPTING GUIDE
Страница 1: ...bbc Adobe Photoshop cs 2 Scripting Guide ...