Hallo,
in my apps I have a repeat that resize my images in photoshop.
I want set a stop button, so I can exit repeat and stop the action.
I’m trying, but it doesn’t work.
I have this code:
if the name of theObject is equal to "start" then
repeat with i from 1 to mycounttot
--my actions
if the name of theObject is equal to "stopp" then
exit repeat
end if
end repeat
I think that the problem is that I have set the stop button inside the button start?
How can I do to set my stop button?
If I set exit repeat outside the repeat obviously it doesn’t work.
It says that this is an AppleScript Studio application so I assume that you have a window where you have both the “Start” and “Stop” buttons to be clicked by the user.
If so, I would say that there is no need for you to put the “Stop” code inside the your repeat block. Instead, have a separate “click” handler for each button, one to start the actions you want, with repeat loop, and another, for “stop”, to invoke actions that would kill the on-going process.
Good luck!
archseed
Model: iBook G3
AppleScript: 1.10.3
Browser: Camino 1.0
Operating System: Mac OS X (10.4)
if the name of theObject is equal to “start” then
set my userCancelled to false
repeat with i from 1 to mycounttot
–my actions
if my userCancelled is true then
exit repeat
end if
end repeat
if the name of theObject is equal to “stop” then
set my userCancelled to true
end if
Just a parting thought…you could perhaps trim your codes by one line by eliminating the “set userCancelled to false” before the repeat loop since the property “userCancelled” is already set to false.