My challenge is to use multiple on dialog ended handlers for the same window, with particular attention to the obvious fact that AppleScript will not allow me to have duplicate handlers.
My first approach was:
on displayDialog(theMsg, theButtonsArray, theDefaultButton, theGivingUp, theIcon, theWindow)
script
property itsMsg : theMsg
property itsButtonsArray : theButtonsArray
property itsDefButton : theDefaultButton
property itsGiveUp : theGivingUp
property itsIcon : theIcon
property itsWindow : theWindow
property dd : null
property theResult : ""
on showItself()
set dd to display dialog itsMsg buttons itsButtonsArray default button itsDefButton ¬
giving up after itsGiveUp with icon itsIcon attached to window itsWindow
end showItself
on dialog ended theObject with reply dd
if (gave up of dd) then
set theResult to itsDefButton
else
set theResult to (button returned of dd)
end if
end dialog ended
end script
end displayDialog
-- for example:
set continueDlg to ¬
displayDialog("You have not finished calculating your Spreadsheet." & return & ¬
"Do you wish to continue calculating?" & return & return, ¬
{"Yes", "No"}, "Yes", 15, "stop", mainWindow)
tell continueDlg to showItself()
set gSaved to (theResult of continueDlg) is "No"
However, when the compiled app is run, I get Error = -1708 which appears to be a generic catch-all error.
I could easily avoid the problem by not using on dialog ended, but call it an academic exercise.
Thanks bunches in advance for your help.