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.

bind time all 4 h

Help for those learning Tcl or writing their own scripts.
Post Reply
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

bind time all 4 h

Post by ranny »

Hello,

I want to send a message in a channel all 4 hours.

I have this code

Code: Select all

bind time - "00 00 *" myproc
bind time - "00 04 *" myproc
bind time - "00 08 *" myproc
bind time - "00 12 *" myproc
bind time - "00 16 *" myproc
bind time - "00 20 *" myproc
There's a more simple solution, shorter :?:

thx
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

timer ? :)
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

You probably mean something like that?! Use your brain, all your hours have a remainder of 0 if you divide them by 4 :D.

Code: Select all

bind time - "00 *" myproc

proc myproc {min h d m y} {
   if {[expr {$h % 4}] == 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...
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

Post by ranny »

De Kus wrote:You probably mean something like that?! Use your brain, all your hours have a remainder of 0 if you divide them by 4 :D.

Code: Select all

bind time - "00 *" myproc

proc myproc {min h d m y} {
   if {[expr {$h % 4}] == 0} {
      ...
   }
}
Yes,thx De Kus.
I use my brain and i see your error :D

The good code is

Code: Select all

if {[expr {[string trimleft $h 0] % 4}] == 0} {
      ...
   }
thx :lol:
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

No need to trim and no need to use expr inside the if statement.
.tcl if {04%4 == 0} { putlog yes }
[23:50] yes
Post Reply