Re: Skip current repeat iteration
Re: Skip current repeat iteration
- Subject: Re: Skip current repeat iteration
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 22 Oct 2002 12:24:24 -0700
On 10/22/02 11:58 AM, "Ken Grimm" <email@hidden> wrote:
>
On 10/22/02 1:11 PM, Paul Berkowitz at email@hidden didst forever and
>
always commit to the digital human communication archive:
>
>
> repeat with i from 1 to n -- or any other repeat loop type
>
> repeat 1 times
>
>
Should that be :
>
>
repeat i times
>
>
??
No it should not! Why would you want to go around the inner loop 100 times?
If something meets the criteria for 'next repeat', whatever that may be
(i.e. x = y, x /= y, or whatever) , exit the inner loop which gets you to
the next main loop iteration. it doesn't really matter if you set a variable
outside or inside the inner loop:
set aList to {1,2,3,4,5,6,7,8}
repeat with from 1 to n
set someVariable to item i of aList
repeat 1 times
set newVariable to someVariable + 10
if someVariable = 17 then
display dialog "You've got a 7 there!"
exit repeat
end if
end repeat
set item i of aList to newVariable
--57 more lines of script
end repeat
--do more stuff with aList, including item 7
obviously, without the extra 57 lines of script, or the need to do anything
if the result is 17, you'd just use an 'else' clause, or exclude 7 like
this:
if someVariable /= 17 -- does not equal
--rest of script
end if
But sometimes things et too complicated to put the exclusion around 58 lines
of script which might contain different try/error and if/else clauses, and
you just want to move on to the next main repeat iteration.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.