I use the following 'run' handler in all of my application scripts.
on run try my main() on error errText number errNr if errNr = -128 then return else if errNr = -2700 then my showInstruction(errText) else my showError(errText, errNr, false) end if end try end run -------------------------------------------------------
If you arrive at a point in your script where you want to simply quit, you use the instruction
If you encounter a condition that does not allow continuation of the script, use this instruction which uses the showInstruction handler
error "Explain to the user why continuation was not possible." -- returns error number -2700
All other errors are unknown to your script and use the showError handler. The showError handler simply shows the error number and text. Here's my showInstruction handler ...
on showInstruction(instText) set dTitle to "Instruction" activate me tell me to display alert dTitle message instText buttons {"Help", "OK"} default button "OK" if (button returned of the result) = "OK" then return tell application "Finder" to open file (((path to me) as text) & pathToHelp) using application file id "com.apple.helpviewer" end showInstruction --------------------------------------------------------
|