Canceling from a progress bar

I work in a magazine publishing prepress environment. I’ve been developing a script that works between Adobe InDesign and Adobe Photoshop that opens selected images placed in the InDesign document, resizes them and rotates them so as they are at 100% scale and 0 degrees rotation in the InDesign document, and crops out extraneous portions of the image. All this works well.

I took this script into AppleScript Studio so as I could elegantly add a progress bar and means of canceling, should the user decide to do so.

The progress bar was no problem - I created a second NIB file, called “load nib” and got handles to all the elements I needed.

My problem is how do I get the script to recognise that the user has pressed the Cancel button and exit the repeat loop in an orderly fashion without leaving an image half processed . Cmd-period will halt the script, but can leave things half finished state, and besides, it’s not as friendly as a Cancel button.

Any suggestions?

Thanks to an example by Jonathan Nathan, I was able to get it to work.

After dissecting the example and finding no major differences with my own script, I thought I was going crazy. But when I removed the second NIB file where my progress panel was residing and reconstructed the progress panel in MainMenu.nib, suddenly the Cancel button was able to set the Property in the script that my repeat loop checked each iteration.

Why the Cancel button would not respond during the running of the repeat loop when residing in a second NIB file, is for a more knowledgeable person than myself to answer.

Thank you Jonathan

Glad you found the example, I was just about to point it out to you myself. For those still interested, see this thread:

http://bbs.applescript.net/viewtopic.php?t=5711

Jon