Catching the "Stop" button, but still stopping

I’m trying to add some error checking so when a user clicks Stop on a progress bar, the problem quits nicely rather than glitches out.

So I put the progress bar action in a try clause. It works, now I can run some commands and handle the stopping nicely.
EXCEPT… the script doesn’t stop :smiley: This is in a loop, and once I run my “on error” commands, it just goes back to the loop.

How to I let the script actually STOP at this point? I’m one or two subroutines deep so ‘return’ also won’t stop the script. And will actually break it even more.

Edit: Moving on in the script, I’m having the same problem with regular dialogs. I’m trying to catch “cancels” and I can, but then the script doesn’t actually stop.

I just discovered “quit me” and I don’t know why the other solutions exist at all. But now I’m putting this all over the place.

You can exit a loop with exit repeat

When pressing the Cancel button AppleScript throws an error -128 which aborts the script immediately unless it’s inside a try block.

However stay open applets behave differently. To quit the applet you have to call quit me explicitly.

1 Like