Re: Timed loop
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
References: | |
| >Timed loop (From: Peter Baxter <email@hidden>) |