• 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: Timed loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Timed loop


  • Subject: Re: Timed loop
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 28 Nov 2007 13:01:32 -0800

On Nov 21, 2007, at 11:15 PM, Peter Baxter wrote:

I would like to run a loop until 10 minutes after it starts. getting the initial date is easy:
set the date_stamp to ((the current date) as string)
however getting the time ten minutes later is problematic. What I would like to do is to repeat until the current date equals date_stamp plus ten minutes.

Simple -- don't coerce "current date" to a string. You can do math on date objects; a date plus an integer number is another date that number of seconds later (or earlier if the number is negative.) There are even some constants to make the math easier. For example:


set now to current date
set later to now + 10 * minutes -- "minutes" is defined as 60, that is, 60 seconds.
repeat while current date < later
-- whatever.
end



--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Timed loop
      • From: Jean-Baptiste LE STANG <email@hidden>
References: 
 >Timed loop (From: Peter Baxter <email@hidden>)

  • Prev by Date: Re: If statements in Excel
  • Next by Date: Re: Script Editor rewrites my script, doesn't like its rewrite
  • Previous by thread: Re: Timed loop
  • Next by thread: Re: Timed loop
  • Index(es):
    • Date
    • Thread