Re: Skip a step in a repeat loop
Re: Skip a step in a repeat loop
- Subject: Re: Skip a step in a repeat loop
- From: Arthur J Knapp <email@hidden>
- Date: Thu, 30 Aug 2001 13:37:19 -0400
>
Date: Thu, 30 Aug 2001 08:39:25 -0700
>
Subject: Re: Skip a step in a repeat loop
>
From: Paul Berkowitz <email@hidden>
>
On 8/30/01 8:06 AM, "Arthur J Knapp" <email@hidden> wrote:
>
> I am so sick of looking at lines of AppleScript code that have 15 to 20
>
> tabs in front of them. I favor a loop-continue statement for the whitespace
>
> savings alone... ;-)
>
Somebody here (I forget whom - perhaps Nigel will remember) [posted a really
>
brilliant workaround - nay, solution - to this problem. I use it all the
>
time. As you say, the if/then stuff gets horribly messy, especially when
>
you're trying to exit long before the end of the repeat loop. Here:
>
repeat with i from 1 to 100 -- or whatever, any sort of repeat loop
>
>
repeat 1 times
>
>
--blah blah
>
if something "what you want" then
>
exit repeat --goes on to next iteratio
>
end if
>
--lots of blah blah
>
--tons of scripting
>
end repeat
>
end repeat
I actually think that this may have been me, though I'm not sure.
>
And if you also need to get out of the "real" repeat loop higher up the
>
script (doesn't happen very often, but just in case - my own contribution
>
today):
>
>
>
repeat with i from 1 to 100 -- or whatever, any sort of repeat loop
>
>
repeat 1 times
>
set realExit to false
>
--blah blah
>
if someParam = "satisfied" then
>
set realExit to true
>
exit repeat
>
end if
>
--blah blah
>
if something "what you want" then
>
exit repeat --goes on to next iteration
>
end if
>
--lots of blah blah
>
--tons of scripting
>
end repeat
>
if realExit then exit repeat
>
end repeat
Good stuff, Paul, but an actual "continue" statement would still
be nicer... ;-)
repeat with i from 1 to 100
-- stuff
if (something) then continue
-- more stuff
...
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.vivaladata.com