| Author |  | 
      
        | onhiatus Senior Member
 
  
  
 Joined: May 12 2004
 Location: United States
 Online Status: Offline
 Posts: 279
 | 
          I'm trying to display (and allow modifying of) the next time a timed event is set to run. I'm using ph_createtimedevent to set up new events, but I can't figure out how to query when a given macro will run next.
           | Posted: November 11 2007 at 23:17 | IP Logged |   |  
           | 
 |  
 Ideally I need two things:
 1) When a given macro is next scheduled to run
 2) A way to delete a one shot timed event.
 
 I would have sworn I've at least seen #2 before, but I am unable to find it. Any suggestions?
 
 Thanks, Tony
 | 
       
        | Back to Top |       | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          I can help you with #2.
           | Posted: November 12 2007 at 07:58 | IP Logged |   |  
           | 
 |  
 PH_DIRECTSQL("DELETE FROM TIMEDEVENTS WHERE FREQUENCY = 0 AND ACTION = 'MBR_TV_OFF'")
 
 MBR_TV_OFF is the ID of the event.
 
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | onhiatus Senior Member
 
  
  
 Joined: May 12 2004
 Location: United States
 Online Status: Offline
 Posts: 279
 | 
          So is MBR_TV_OFF the name of the macro scheduled to run, or is it a unique record id?
           | Posted: November 12 2007 at 12:29 | IP Logged |   |  
           | 
 |  
 If it's the macro name how does the above deal when there are multiple events scheduled?
 
 Thanks, Tony
 | 
       
        | Back to Top |       | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          It is the value in the ID field of the Create Timed Event that you created for the one shot.
           | Posted: November 12 2007 at 13:58 | IP Logged |   |  
           | 
 |  
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | onhiatus Senior Member
 
  
  
 Joined: May 12 2004
 Location: United States
 Online Status: Offline
 Posts: 279
 | 
          Shoot, what I'm hoping for is to be able to search / delete based on some generic value that the code has. The code probably didn't create the timed even, so it doesn't know the id.
           | Posted: November 12 2007 at 17:27 | IP Logged |   |  
           | 
 |  
 Any other suggestions?
 
 Thanks, T
 | 
       
        | Back to Top |       | 
       
       
        |  | 
        | onhiatus Senior Member
 
  
  
 Joined: May 12 2004
 Location: United States
 Online Status: Offline
 Posts: 279
 | 
          A little further research has gotten me closer. See posting 530.
           | Posted: November 12 2007 at 18:18 | IP Logged |   |  
           | 
 |  
 The following should delete all one shot timed eventr running the macros MY_MACRO (use inside a ph_directsql function call):
 delete from timedevents where frequency = 0 and action = 'MY_MACRO'
 
 Even better, this should only delete the next one shot timed event:
 delete from timedevents where
 action='MY_MACRO'
 and frequency=0
 and starttime=(select min(starttime) from timedevents where
 action='MY_MACRO'
 and frequency=0)
 
 So, getting the start times for all one shot timed events that execute 'MY_MACRO' should look something like:
 select * from timedevents where
 action='MY_MACRO'
 and frequency=0
 Or just the next one shot event running MY_MACRO:
 select min(starttime)from timedevents where
 action='MY_MACRO'
 and frequency=0
 
 So, assuming that the ph_directsql() function returns selects as text I have everything I need... I'm not at home right now, so I can't test, but I'm hopeful...
 
 Dave, do we need a SQL section to the board?
 
 | 
       
        | Back to Top |       | 
       
       
        |  | 
        | onhiatus Senior Member
 
  
  
 Joined: May 12 2004
 Location: United States
 Online Status: Offline
 Posts: 279
 | 
          Even more research (See post 926) yields
           | Posted: November 12 2007 at 19:16 | IP Logged |   |  
           | 
 |  
 ph_sqlselectinto(1,"select min(starttime)from timedevents where action='MY_MACRO' and frequency=0")
 
 This should place the execution time of the next timed event running 'MY_MACRO' to [LOCAL1]
 
 Thanks for the help! Tony (The other one)
 
 | 
       
        | Back to Top |       | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          OK, I'll pass on this one. You just jumped above my job description... I come from the old Fortran, Cobol, PL/1 Assembler days.
           | Posted: November 12 2007 at 19:27 | IP Logged |   |  
           | 
 |  
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  |