Seconds until next tock
Seconds until next tock
- Subject: Seconds until next tock
- From: Gil Dawson via AppleScript-Users <email@hidden>
- Date: Sat, 17 Aug 2019 15:45:17 -0700
Hi--
I needed something to execute at a regular interval, on the rounded interval
seconds.
--Gil
repeat 4 times
log "The current time is " & time string of (current date)
delay SecondsUntilNextTock(20, 3)
end repeat
-->
(*The current time is 3:26:43 PM*)
(*The current time is 3:27:00 PM*)
(*The current time is 3:27:20 PM*)
(*The current time is 3:27:40 PM*)
on SecondsUntilNextTock(Tock, MinRunSecs)
set Now to current date
set NowSec to ((hours of Now) * hours) + ((minutes of Now) * minutes) +
(seconds of Now)
set LastTock to (NowSec div Tock) * Tock
set LastTockTime to Now - NowSec + LastTock
set NextTockTime to LastTockTime + Tock
set SecsUntilNextTock to NextTockTime - Now
repeat until SecsUntilNextTock ≥ MinRunSecs -- if the next execution
would come too soon...
set NextTockTime to NextTockTime + Tock --skip an interval
set SecsUntilNextTock to NextTockTime - Now
end repeat
return SecsUntilNextTock
end SecondsUntilNextTock
_______________________________________________
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