
Photoshop 7.0 Scripting Guide
20
Scripting basics
Handlers, subroutines and functions
2
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.8 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.
AS
set flag to DoConfirm("Are you sure?")
display dialog flag as string
on DoConfirm(prompt)
set button to button returned of (display dialog prompt ¬
buttons {"Yes", "No"} default button 1)
return button = "Yes"
end DoConfirm