Page 1 of 1

Time 'til next action?

PostPosted: Tue Jul 24, 2007 5:59 pm
by SSneddon
The main window shows a value for time to next action. Is there a way to get this in an applescript?

Thanks,

Scott

Re: Time 'til next action?

PostPosted: Tue Jul 24, 2007 9:50 pm
by matt (support)
Hi Scott,

The only way to get it from AppleScript is to loop through all of the time date actions looking for the most recent next trigger time property.

Regards,
Matt

here's my snippet for timeofnextevent, and nameofnextevent

PostPosted: Sun Aug 12, 2007 8:50 am
by SSneddon
Here's how I did it in my system. I included this in an attachment script with other misc functions. Note that it ignores events that are not enabled.

Code: Select all
using terms from application "IndigoServer"
   
   on timeofnextevent()
      set nextevent to date "Friday, April 4, 2025 12:00:00 AM"
      repeat with thisevent in every time date action
         if enabled of thisevent is true then
            if (next trigger time of thisevent as date) < nextevent then
               set nextevent to (next trigger time of thisevent as date)
            end if
         end if
      end repeat
      return nextevent
   end timeofnextevent
   
   on nameofnextevent()
      set nextevent to date "Friday, April 4, 2025 12:00:00 AM"
      repeat with thisevent in every time date action
         if enabled of thisevent is true then
            if (next trigger time of thisevent as date) < nextevent then
               set nextevent to (next trigger time of thisevent as date)
               set nexteventname to name of thisevent
            end if
         end if
      end repeat
      return nexteventname
   end nameofnextevent
end using terms from


the initialization of the nextevent variable to a date in 2025 is a little ugly, but I wasn't sure of a more elegant way to do it.

Scott.