Photoshop CS Scripting Guide
25
Scripting basics
Handlers, subroutines and functions
2
VB
flag = False
Do While flag = False
retVal = MsgBox("Quit?", vbOKCancel)
If (retVal = vbCancel) Then
flag = True
End If
Loop
flag = False
Do Until flag = True
retVal = MsgBox("Quit?", vbOKCancel)
If (retVal = vbOK) Then
flag = True
End If
Loop
JS
var flag = false;
while (flag == false)
{
flag = confirm("Are you sure?");
}
var flag = false;
do
{
flag = confirm("Are you sure?");
}
while (flag == false);
2.9 Handlers, subroutines and functions
Subroutines, or handlers (in AppleScript) and functions (in JavaScript), are scripting modules
you can refer to from within your script. These subroutines provide a way to re-use parts of
scripts. Typically, you send one or more values to a subroutine and it returns one or more
values.
There’s nothing special about the code used in subroutines — they are conveniences that save
you from having to retype the same code lines in your script.