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.

about timer

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

about timer

Post by ultralord »

hello .. how i can put timer command on tcl script.. i want every 5 minites to run one variable.. etc..

Code: Select all

proc test

timer 5 timer ?
how i can do this?

thanks you
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Either use a time-binding, or make a call to the timer command from within your proc.
NML_375
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Either use bind time:

Code: Select all

bind time {?0 * * * *} myproc
bind time {?5 * * * *} myproc

proc myproc {min hour day month year} {
  # do my stuff here
}
Or just keep setting a timer:

Code: Select all

timer 5 [list myproc ?proc arguments?]

proc myproc {?proc arguments?} {
  # do my stuff here
  timer 5 [list myproc ?proc arguments?]
}
Hope this helps!
r0t3n @ #r0t3n @ Quakenet
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

because i am confused..

i want after 5 minites one proc run..

#procname : Delete

proc Delete
............
.....

utimer 5 Delete.. (and after 5 minites "Delete" is running)

something like that.. ?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

timer and utimer delays the execution of a command by the time you specify (timer delays n minutes, while utimer delays n seconds).
Neither timer or utimer will repeat the command, bur simply execute it once after the specified delay, and they do not block execution of code while "counting down".

In your case,

Code: Select all

utimer 5 Delete
would cause your script to execute the command Delete after 5 seconds.
NML_375
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

yes i want to run the proc DELETE always afte 5 minites like..


timer 5 DELETE

something like that?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

nml375 already made it clear that a timer will call the procedure only ONCE after n minutes. It is up to you to call the timer again inside your procedure each time it's called.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

ultralord wrote:yes i want to run the proc DELETE always afte 5 minites like..


timer 5 DELETE

something like that?
Then you need something like this:

Code: Select all

timer 5 [list delete $args]

proc delete {args} {
  #do your stuff here
  
  ###
  #call timer to repeat execution
  timer 5 [list delete $args]
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

fixed thnx
Post Reply