How to Quit inside a subroutine

I want to quit the script if a certain situation is true.
I have several subroutines and my script will go down the list as it should.
But, at the end, where I want it to end the script, it will put up the display and then return to the script way back up at the top and run the second scenario right after the first. (I hope I explained that well.)

I created an additional sub-routing to quit the script but it quits “Finder” instead. The “Display ad v4.6” is the name of the script saved as an application.

on quitScript()
set adRunList to {}
tell application “Display ad v4.6”
end tell
end quitScript

Any ideas? If it will help to post the script I can but it is quite long.

Thank you,


Probably the reason why you’re getting this is because your stuff is located in a Finder tell block. I gotta go back and read your post but I don’t like to use nested tell blocks when other avenues are possible.

If you just want the script to quit immediately without further comment, use error number -128. This is the same error that’s generated when you click ‘Cancel’ in a dialog.

if situationIsTrue then
  error number -128
end if

The error -128 worked perfectly. I’ll remember that from now on.
I’ve said it before but here it is again,

       Thank you for this site. I get so many questions answered here that I rarely have to post anything but when I do the responses are prompt and almost always exactly what I need.