This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

blind time.

Help for those learning Tcl or writing their own scripts.
Post Reply
c
c0re
Voice
Posts: 16
Joined: Sun Jan 18, 2009 4:45 pm

blind time.

Post by c0re »

Hi, i want to blind time every 4 sec. how do i do it?

bind time -|- {* * * * *} proc_update

i dont how to set second. please help
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The time binding's resolution is down to the minute, so you cannot use that for anything shorter. The most common approach is to use recursive utimer calls:

Code: Select all

proc someproc {} {
  #payload here...


  #now for the recursive calling:
  #First check for existing timers...
  if {[lsearch [utimers] "* someproc *"] == -1} {
    #No timers left, start a new one
    utimer 4 [list someproc]
  }
}
someproc
This is a rough skeleton, with a few shortcuts. The check for running timers could probably be prettier, but should do the trick as long as you don't use very complex proc-names..
NML_375
c
c0re
Voice
Posts: 16
Joined: Sun Jan 18, 2009 4:45 pm

Post by c0re »

Thank you for your quick reply.....

Code: Select all

proc livefeed {} { 

  set pagina "my url" 
  set http [http::config -useragent mozilla] 
  set http [http::geturl $pagina -timeout [expr 1000 * 10]] 
  set html [http::data $http] 
  foreach line [split $html "\n"] {
  putlog "upgrading livefeed." 

  if {[lsearch [utimers] "* livefeed *"] == -1} { 
    #No timers left, start a new one 
    utimer 5 [list livefeed] 
  } 
} 
question is how do i bind it? with timer or something?
c
c0re
Voice
Posts: 16
Joined: Sun Jan 18, 2009 4:45 pm

Post by c0re »

i figured it out and its work just great.....

Code: Select all

proc livefeed {} { 

  set pagina "my url" 
  set http [http::config -useragent mozilla] 
  set http [http::geturl $pagina -timeout [expr 1000 * 10]] 
  set html [http::data $http] 
  putlog "upgrading livefeed." 

  if {[lsearch [utimers] "* livefeed *"] == -1} { 
    #No timers left, start a new one 
    utimer 8 [list livefeed] 
  } 
} 
livefeed
Thank you so much....
Post Reply