Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Code for deleting a timed event? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: November 11 2007 at 23:17 | IP Logged Quote onhiatus

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 View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 12 2007 at 07:58 | IP Logged Quote BeachBum

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 View BeachBum's Profile Search for other posts by BeachBum
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: November 12 2007 at 12:29 | IP Logged Quote onhiatus

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 View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 12 2007 at 13:58 | IP Logged Quote BeachBum

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 View BeachBum's Profile Search for other posts by BeachBum
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: November 12 2007 at 17:27 | IP Logged Quote onhiatus

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 View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: November 12 2007 at 18:18 | IP Logged Quote onhiatus

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 View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: November 12 2007 at 19:16 | IP Logged Quote onhiatus

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 View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 12 2007 at 19:27 | IP Logged Quote BeachBum

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 View BeachBum's Profile Search for other posts by BeachBum
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum