<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/9941" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2007-07-30T16:00:52-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/9941</id>

		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-07-24T06:32:11-04:00</updated>

		<published>2007-07-24T06:32:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=74716#p74716</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=74716#p74716"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=74716#p74716"><![CDATA[
<blockquote class="uncited"><div>Hint:<br><br>To trim the minutes (or other vars) best use:<br><div class="codebox"><p>Code: </p><pre><code>set minutes [string trimleft $minutes 0]; if {$minutes==""} {set minutes 0}</code></pre></div></div></blockquote>Or simply convert it to decimal as done in my code above:<div class="codebox"><p>Code: </p><pre><code>set minutes [scan $minutes %d]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Tue Jul 24, 2007 6:32 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2007-07-24T10:56:29-04:00</updated>

		<published>2007-07-24T01:27:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=74709#p74709</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=74709#p74709"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=74709#p74709"><![CDATA[
The mask is "MM HH dd mm yyyy" and can have wildcards (MM=minute, HH=hour, dd=day, mm=month(-1), yyyy=year)<br><br>The month comes with -1. So, january is 00 and december is 11.<br><br>Examples:<br><div class="codebox"><p>Code: </p><pre><code>bind time - * procname ; # is called every minutebind time - "?5 *" procname ; # is called every 10 minutes, 05,15,25,35,45,55bind time - "30 *" procname ; # is called every hour, 30 mins after fullbind time - "30 1? * 200?" procname ; # work from 10:30 - 19:30 every hour, but only in the year 2000-2009</code></pre></div><div class="codebox"><p>Code: </p><pre><code>proc procname {minute hour day month year} { .. } ; # full var supportproc procname {min hour args} { .. } ; # args is special var for a listproc procname args { .. } ; # you dont need the time, only proc called</code></pre></div>Hint:<br><br>To trim the minutes (or other vars) it is best to use:<br><div class="codebox"><p>Code: </p><pre><code>set minutes [string trimleft $minutes 0]; if {$minutes==""} {set minutes 0}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Tue Jul 24, 2007 1:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-05-13T17:24:13-04:00</updated>

		<published>2007-05-13T17:24:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=72749#p72749</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=72749#p72749"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=72749#p72749"><![CDATA[
In case you are worried about minute intervals which are not divisible by 60, there is a solution. What I mean by "not divisible by 60" are intervals like 7 for example: 00, 07, 14, 21, 28, 35, 42, 49, 56 - now the operation should be performed at minute 03 but instead it triggers at minute 00 which is not after 7 minutes. To solve this, you can use:<div class="codebox"><p>Code: </p><pre><code>bind time - * operation# This proc (operation) is called every minute (00, 01, 02, 03,...59)proc operation {min hour day mon year} { # We want to trigger our command every 7 minutes if {([scan $min %d]+([scan $hour %d]*60)) % 7 == 0} {  # Perform the needed operation here }}</code></pre></div>What's happening here is that the hour is being converted into its minutes equivalent, added to the minute, and then divided by the interval to check if the remainder is 0. This way the difference between every call of the needed operation is always 7 minutes.<br><br>This, of course, can be applied on all intervals (divisible or not divisible by 60) so I recommend using it as default.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sun May 13, 2007 5:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-05-10T16:51:32-04:00</updated>

		<published>2007-05-10T16:51:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=72636#p72636</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=72636#p72636"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=72636#p72636"><![CDATA[
<blockquote class="uncited"><div><strong class="text-strong">TIME</strong> (stackable)<br>bind time &lt;flags&gt; &lt;mask&gt; &lt;proc&gt;<br>proc-name &lt;minute&gt; &lt;hour&gt; &lt;day&gt; &lt;month&gt; &lt;year&gt;<br><br>Description: allows you to schedule procedure calls at certain<br>times. mask matches 5 space separated integers of the form:<br>"minute hour day month year". minute, hour, day, month have a<br>zero padding so they are exactly two characters long; year is<br>four characters. Flags are ignored.</div></blockquote>What's also worth mentioning about the time bind is that the first day is 01 and the first month is 00 (this is not documented).<br><br>If you want to trigger an operation every x minutes without using the (u)timer command, then bind time is what you need. Example:<div class="codebox"><p>Code: </p><pre><code>bind time - * operation# This proc (operation) is called every minute (00, 01, 02, 03,...59)proc operation {min hour day mon year} { # We want to trigger our command every 3 minutes for example if {[scan $min %d] % 3 == 0} {  # Perform the needed operation here }}</code></pre></div>[scan %d] is applied over $min in order to convert it from an octal to a decimal number (since 08 &amp; 09 are invalid octals) to be divided over the number of minutes (the interval of your choice which is 3 in our example). If the remainder is not 0 (greater than 0) then $min is not divisible by 3 and thus 3 minutes did not pass. This means that the "needed operation" is triggered at minutes 00, 03, 06, 09, ..., 57 (all divisible by 3).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Thu May 10, 2007 4:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2007-05-08T21:49:25-04:00</updated>

		<published>2007-05-08T21:49:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=72613#p72613</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=72613#p72613"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=72613#p72613"><![CDATA[
Since we are dealing with timers here, some info regarding the minute, hour, day, month, year masks for <em class="text-italics">bind time</em> and how they are used for specific intervals would be appreciated.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Tue May 08, 2007 9:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2005-09-08T10:26:07-04:00</updated>

		<published>2005-09-08T10:26:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=55454#p55454</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=55454#p55454"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=55454#p55454"><![CDATA[
Btw, [timerexists] and [utimerexists] are <strong class="text-strong">alltools.tcl</strong> commands. Incase you're not loading it:<div class="codebox"><p>Code: </p><pre><code>proc timerexists {command} {  foreach i [timers] {    if {![string compare $command [lindex $i 1]]} then {      return [lindex $i 2]    }  }  return}proc utimerexists {command} {  foreach i [utimers] {    if {![string compare $command [lindex $i 1]]} then {      return [lindex $i 2]    }  }  return}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Thu Sep 08, 2005 10:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2005-08-08T18:43:59-04:00</updated>

		<published>2005-08-08T18:43:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53896#p53896</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53896#p53896"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53896#p53896"><![CDATA[
Incase you have a timer which has more than 1 element in it and some of these elements always vary (i.e. $nick $uhost...etc) then you can use string match instead of string equal to be able to use wildcards. Suppose we have:<blockquote class="uncited"><div>{12 {check:voices #bla} timer1}</div></blockquote>We can use this code to find and kill this timer:<div class="codebox"><p>Code: </p><pre><code>foreach thetimer [timers] {  if {[string match -nocase "check:voices *" [lindex $thetimer 1]]} {   # got a match   killtimer [lindex $thetimer 2]   # killed the timerID which is the 3rd element of $thetimer.   break   # stopped since no need for further checks.  } }</code></pre></div>And ofcourse you can also use "lsearch -glob"<div class="codebox"><p>Code: </p><pre><code>if {[set timerindex [lsearch -glob [timers] "* {check:voices *} *"]] != -1} {  # if it's == -1 then it doesn't exist, otherwise it returns the index of this timer.  killtimer [lindex [lindex [timers] $timerindex] 2]  # the 3rd element of this list is the timerID which is now killed. }</code></pre></div>but the first method is faster.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Mon Aug 08, 2005 6:43 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[sKy]]></name></author>
		<updated>2005-07-12T16:17:42-04:00</updated>

		<published>2005-07-12T16:17:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=52358#p52358</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=52358#p52358"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=52358#p52358"><![CDATA[
i might add:<div class="codebox"><p>Code: </p><pre><code>timer time command</code></pre></div><blockquote class="uncited"><div>returns timerID</div></blockquote>example: set timer [timer 1 [list putserv "..."]]<br>same for utimer.<br><br>this timer-id can you put in a variable (perhaps a global variable) and use later.<br><br>some less important procs:<div class="codebox"><p>Code: </p><pre><code>proc isutimer { id } {foreach utimer [utimers] {set isid [lindex $utimer 2]if { $id == $isid } {return 1}}return 0}proc istimer { id } {foreach timer [timers] {set isid [lindex $timer 2]if { $id == $isid } {return 1}}return 0}</code></pre></div>Ex:<blockquote class="uncited"><div>if { [istimer $timerid] } { killtimer $timerid }</div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6101">sKy</a> — Tue Jul 12, 2005 4:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2005-07-02T18:33:51-04:00</updated>

		<published>2005-07-02T18:33:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=51682#p51682</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=51682#p51682"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=51682#p51682"><![CDATA[
You can also search for a timer independant from any cases (capital or lower letters) using lsearch.<div class="codebox"><p>Code: </p><pre><code>lsearch -glob [string tolower [timers]] "* {check:voices} *"</code></pre></div>but note that check:voices should be in lowercase as well. so if you want to make sure that a variable is in lowercase use<div class="codebox"><p>Code: </p><pre><code>string tolower $variable</code></pre></div>PS: After a test of which method is faster (lsearch or foreach and matching) I found out that using the foreach method is faster.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sat Jul 02, 2005 6:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-07-30T16:00:52-04:00</updated>

		<published>2005-06-22T19:54:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=51260#p51260</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=51260#p51260"/>
		<title type="html"><![CDATA[Timers (Searching, killing, using time binds)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=51260#p51260"><![CDATA[
Catching if a certain timer is running, then kill it.<br><br>There're several ways to do so, for example suppose we have a timer that should execute the proc check:voices.<div class="codebox"><p>Code: </p><pre><code>timerexists check:voices</code></pre></div>this code returns the timer id of the timer which should execute check:voices. So to catch it and kill it, we can use:<div class="codebox"><p>Code: </p><pre><code>if {[set thetimer [timerexists check:voices]]!=""} { # if it's == "" then it doesn't exist, otherwise it returns the timerID killtimer $thetimer # timer is killed}</code></pre></div>another way would be to use lsearch with the glob switch.<div class="codebox"><p>Code: </p><pre><code>if {[set timerindex [lsearch -glob [timers] *check:voices*]] != -1} { # if it's == -1 then it doesn't exist, otherwise it returns the index of this timer. killtimer [lindex [lindex [timers] $timerindex] 2] # the 3rd element of this list is the timerID which is now killed.}</code></pre></div>Now the previous 2 methods will not match if there's a difference in case (i.e. Upper or Lower letters.)<br>So this way will match whatever case is used.<div class="codebox"><p>Code: </p><pre><code>foreach thetimer [timers] { if {[string equal -nocase check:voices [lindex $thetimer 1]]} {  # got a match  killtimer [lindex $thetimer 2]  # killed the timerID which is the 3rd element of $thetimer.  break  # stopped since no need for further checks. }}</code></pre></div>Same methods can be applied to utimers, just change timer(s) to utimer(s).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Wed Jun 22, 2005 7:54 pm</p><hr />
]]></content>
	</entry>
	</feed>
