Author |
|
onhiatus Senior Member
Joined: May 12 2004 Location: United States
Online Status: Offline Posts: 279
|
Posted: November 11 2007 at 23:17 | IP Logged
|
|
|
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.
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
|
Posted: November 12 2007 at 07:58 | IP Logged
|
|
|
I can help you with #2.
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
|
Posted: November 12 2007 at 12:29 | IP Logged
|
|
|
So is MBR_TV_OFF the name of the macro scheduled to run, or is it a unique record id?
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
|
Posted: November 12 2007 at 13:58 | IP Logged
|
|
|
It is the value in the ID field of the Create Timed Event that you created for the one shot.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
onhiatus Senior Member
Joined: May 12 2004 Location: United States
Online Status: Offline Posts: 279
|
Posted: November 12 2007 at 17:27 | IP Logged
|
|
|
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.
Any other suggestions?
Thanks, T
|
Back to Top |
|
|
onhiatus Senior Member
Joined: May 12 2004 Location: United States
Online Status: Offline Posts: 279
|
Posted: November 12 2007 at 18:18 | IP Logged
|
|
|
A little further research has gotten me closer. See posting 530.
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
|
Posted: November 12 2007 at 19:16 | IP Logged
|
|
|
Even more research (See post 926) yields
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
|
Posted: November 12 2007 at 19:27 | IP Logged
|
|
|
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.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|