Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schedule an event

Status
Not open for further replies.

101gary

Programmer
May 2, 2007
3
GB
Hi
I am currently writing a linux dvb veiwer/recorder as a front end to Mplayer.

I have implemented veiwing and recording on the fly but I would like to add a function to record the current channel at a specific time and end the recording at a specific time.

How do I write a function that will constantly check whether the time criteria has been met without interrupting the current function for viewing a dvb channel?

Any guidance appreciated.
 
Ok, after some thought I am writing a simple dummy program to schedule an event for a certain time

Problem is the scheduled messagebox does not appear, I am fairly new to TCL so I am not sure about the correct format for time, so berhaps the argument for the IF is wrong!? Perhaps someone could have a look at the code below and see where the problem lies
Thanks.
Gary

#!/usr/bin/wish

proc clock:set var {
global $var

set $var [clock format [clock seconds] -format %H:%M:%S]
if {$var == "12:53:00"} {
tk_messageBox -message "Time is 12.53" -type ok -icon error
after 800 [list clock:set $var]
} else {
after 800 [list clock:set $var]}
}

pack [label .l -textvariable myclock]
clock:set myclock
 
Have played around and answered my own question.

Instead of using the variable as the argument for the conditional statement I used the clock command itself and it seems to work fine, see code below.

I can now model my scheduler on this.

Thanks anyway.

Gary

#!/usr/bin/wish

proc clock:set var {
global $var

set $var [clock format [clock seconds] -format %H:%M:%S]
if {[clock format [clock seconds] -format %H:%M:%S] == "22:37:00"} {
tk_messageBox -message "Time is [clock format [clock seconds] -format %H:%M:%S]" -type ok
after 600 [list clock:set $var]
} else {
after 600 [list clock:set $var]}

}

pack [label .l -textvariable myclock]
clock:set myclock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top