• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re:"Continue" repeat
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:"Continue" repeat


  • Subject: Re:"Continue" repeat
  • From: George Mack <email@hidden>
  • Date: Wed, 29 Aug 2001 23:21:35 -0400

Matthew Broms <email@hidden> asked:

Is there a way to skip through one cycle of a repeat loop? I don't want to
break out of it, I just want to test on a condition, and if it's true, skip
the rest and jump right to the next item/step in the loop.

The "if/end if" structure does exactly the same thing as continue
when embedded in a repeat loop. The next iteration of the repeat is
almost an implied "else".

Look in the event log at the results of running this script:

---- script
repeat with i from 1 to 10
log i -- to log that repeat is entered, and when.
-- obviously this line was just for this demonstration
if i mod 2 is 0 then
say "even"
end if
end repeat
---- end script

-- event log
(*1*)
(*2*)
tell current application
say "even"
(*3*)
(*4*)
say "even"
(*5*)
(*6*)
say "even"
(*7*)
(*8*)
say "even"
(*9*)
(*10*)
say "even"
end tell
-- end event log

The loop skips completely to the next iteration if the test "i mod 2
is 0" is not true. You could try other test structures if you think
this is too simple but with a properly specified test, you should
find this works exactly like continue would in other languages.

You might even say that "continue" is implicit in the nature of the
loop, unless specifically exited. Its necessity in other languages
seems to depend more on their behind-the-scenes syntactical needs
than on the demands of logic. (But since I haven't done much in any
of those languages for a few years, I'm open to remonstrance from
the gentle reader.)

Hope this helps.

George
--
GEORGE MACK DESIGN - Scituate, MA 02066 - (781) 544-3880
Design-Illustration-Desktop Publishing-Miscellaneous Magic
"Think outside the box? I live there."


  • Prev by Date: Re: processing time & stack overflow
  • Next by Date: Re: processing time & stack overflow
  • Previous by thread: Re: Outlook Express Attachments
  • Next by thread: Double Tell and Outlook...possible?
  • Index(es):
    • Date
    • Thread