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.

is it correct?

Help for those learning Tcl or writing their own scripts.
Post Reply
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

is it correct?

Post by honeybee »

I'm trying to make a time check bind to hit routine:check proc after every 3 hours. i guess its not the correct way, btw. with current version of tcl we can directly do it instead of making bind for everyhour and checking inside the proc?

bind time - "*0 * * * *" routine:check
bind time - "* */3 * * *" routine:check
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind time - "00 *" routine:check

proc routine:check {m h args} {
 if {[scan $h %d]%3 != 0} {return 0}
 # do your stuff here
}
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

Thanks, i was thinking to use.

Code: Select all

if {[expr $hour % 3]} { return }
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

which basicly does the same, since the expression will return doing nothing, if the reminder is not 0...
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Yes, but the number needs to be converted to decimal because 08 and 09 are not valid octal numbers.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

oh, I didnt preconceive that. You are totally right. I wondered why you used scan to get the integer :D. Alternately you could simply use [string trimleft $h 0] :). I'd guess it would be faster.
StarZ|De_Kus ?calc 08 % 3
-[-RO^Bot-]- Fehler: expected integer but got "08" (looks like invalid octal number)
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Post Reply