Photoshop CS Scripting Guide
26
Scripting basics
Debugging and Error Handling
2
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
VB
Private Sub ScriptSample_Click(Index As Integer)
result = DoConfirm("Are you sure?")
MsgBox (result)
End Sub
Function DoConfirm(prompt) As Boolean
buttonPressed = MsgBox(prompt, vbYesNo)
DoConfirm = (buttonPressed = vbYes)
End Function
JS
var theResult = DoConfirm( "Are you sure?" );
alert(theResult);
function DoConfirm(message)
{
var result = confirm(message);
return result;
}
2.10 Debugging and Error Handling
Scripting environments provide tools for monitoring the progress of your script while it is
running, which make it easier for you to track down any problems your script might be
encountering or causing.