Re: "Next" in Repeat?
Re: "Next" in Repeat?
- Subject: Re: "Next" in Repeat?
- From: "Arthur J Knapp" <email@hidden>
- Date: Tue, 23 Jan 2001 12:03:55 -0500
>
Date: Tue, 23 Jan 2001 10:26:21 -0500
>
Subject: "Next" in Repeat?
>
From: Steve Ivy <email@hidden>
>
I'm still kinda new to AppleScript - is there a way to break out of the
>
current loop in a repeat statement and skip to the next one?
What AppleScript is missing, of course, is a "continue"
statement for skipping the rest of a single iteration of
a repeat loop.
>
repeat with i in {1,2,3}
>
if i is "2"
exit repeat -- this will skip out of the repeat all together
>
else
>
log (i)
>
end if
>
end repeat
To "skip" to the next iteration:
>
repeat with i in {1,2,3}
if (i's contents) is not 2 then
>
log (i)
Since there is no "else", only statements inside the "if"
statement are executed. You effectively skip loop 2.
>
end if
>
end repeat
Note: When you work with the "repeat with Variable in List"
syntax, and then you want to test "Variable" for
equality, you need to "dereference" it by using the
keyword "contents".
repeat with i in {1, 2, 3}
i -- item 1 of {1, 2, 3}
contents of i -- 1
--
{
Arthur J Knapp, of STELLARViSIONs ;
http://www.STELLARViSIONs.com ;
mailto:email@hidden ;
"...well the rain falls down
without my help, I'm afraid
and my lawn gets wet,
though I withheld my consent..."
}