These two subroutines will display dialogs which will end execution of the program if the user cancels (the return value is a return command), rather than displaying another dialog informing the user that he or she just clicked the cancel button (“User knows user canceled, user just finished clicking the stinking button.”). The first just displays a message, the second includes a blank for text.
The subroutines can be called from a library, so you can call your non-intrusive display dialog in a single line of code.
OS version: OS X
---------------------------------------------------------
on display_message_dialog(dialogText)
try
tell application "Finder" to display dialog dialogText
on error errMsg number errnum
if errnum is -128 then --If user canceled
return return
else
error errMsg
end if
end try
return
end display_message_dialog
---------------------------------------------------------
on display_text_dialog(dialogText)
try
tell application "Finder" to set dialogResults to display dialog dialogText default answer ""
on error errMsg number errnum
if errnum is -128 then --If user canceled
return return
else
error errMsg
end if
end try
return text returned of dialogResults
end display_text_dialog