Reputation: 91
The script uses idle handler that runs every 5 minutes and alerts me to perform the task. But the script always runs late by 10-40 seconds. I am not sure why that is happening.
global numberOfBeeps, beepcycle
on idle
if beepcycle is greater than 0 then
say "Update 5 minute data and watchlist " using "Serena"
set beepcycle to beepcycle - 1
else
say "Update 30 minute data and watchlist" using "Kate"
set beepcycle to 5
end if
return 300
end idle
on run
set beepcycle to 6
end run
Upvotes: 0
Views: 109
Reputation: 1878
The if statement in your script adds this 10-40 seconds to the on idle handler. So, you should correct the return time of on idle handler some way. For example, you can do something like this:
global numberOfBeeps, beepcycle
on idle
set currentDate to (get current date)
if beepcycle is greater than 0 then
say "Update 5 minute data and watchlist " using "Serena"
set beepcycle to beepcycle - 1
else
say "Update 30 minute data and watchlist" using "Kate"
set beepcycle to 5
end if
set timeElapsed to (get current date) - currentDate
return (300 - timeElapsed)
end idle
on run
set beepcycle to 6
end run
Upvotes: 2