<?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/20215" />

	<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>2016-09-13T16:50:49-04:00</updated>

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

		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-13T16:50:49-04:00</updated>

		<published>2016-09-13T16:50:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105429#p105429</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105429#p105429"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105429#p105429"><![CDATA[
<blockquote class="uncited"><div>Ok.<br><br>I'm not understanding you very well.<br><br>That, in combination with not having the script to see what you are actually doing, is causing this to be much more difficult than it should be.<br><br>I wish you the best of luck with it.</div></blockquote>Ok, thanks.<br><br>According to what I read, the error that arises is due to format of clock command, the way you suggested me.<br><a href="http://wiki.tcl.tk/13094" class="postlink">Info</a> <a href="http://www.rkeene.org/projects/tcl/tcl.fossil/tktview/1929060" class="postlink">Info2</a><br><br>I'll see what I can fix it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Tue Sep 13, 2016 4:50 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-12T13:07:23-04:00</updated>

		<published>2016-09-12T13:07:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105425#p105425</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105425#p105425"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105425#p105425"><![CDATA[
Ok.<br><br>I'm not understanding you very well.<br><br>That, in combination with not having the script to see what you are actually doing, is causing this to be much more difficult than it should be.<br><br>I wish you the best of luck with it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Mon Sep 12, 2016 1:07 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-12T12:39:44-04:00</updated>

		<published>2016-09-12T12:39:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105424#p105424</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105424#p105424"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105424#p105424"><![CDATA[
With added lines do not work ..<br>Something is wrong....<br><strong class="text-strong">Tcl error [pub_setdj]: input string does not match supplied format</strong><br><br>I tried it in two different ways:<br><strong class="text-strong">1)</strong> Invoking the addjss process with the hespad variable in the pub_setdj process, in the latter process it is where the variable hespad sets and where invoked before making changes and it worked. <div class="codebox"><p>Code: </p><pre><code>addjss $hespad</code></pre></div>Then <div class="codebox"><p>Code: </p><pre><code>proc addjss { hespad } {global canal_adminif {![file exists djnick]} { return }set fname0 "djnick"set fp [open $fname0 "r"]set data [read -nonewline $fp]close $fpset lines [split $data " "]set addjs [lindex $lines 0]set datehour [lrange $lines 3 end]if {![file exists listaDJS]} {set fs [open listaDJS "w"]puts $fs ""close $fs} else {set now [clock seconds]set then [clock scan $hespad -format " %A %d de %B a las %H:%M:%S"]if {[expr $now - $then] &gt; 14400 } { set fname "listaDJS"set fp [open $fname "a"] puts $fp "$addjs $datehour"close $fp } else { putquick "PRIVMSG $canal_admin :this issue is not stored";return }}}</code></pre></div><strong class="text-strong">2)</strong> As seen above, the variable $hespa was stored on the djnick file in the pub_setdj process.<br>Thus: <div class="codebox"><p>Code: </p><pre><code>set horadjend [clock seconds]set hespad [clock format [clock scan "0 day" -base [clock seconds]] -format " %A %d de %B a las %H:%M:%S"]set temp [open "djnick" w+]puts $temp "$bajardj $horadjend $hespad"close $temp</code></pre></div>Given this, it takes the value of the variable directly from djnick file ($datehour) and invoke the process without the variable (as he had done before and it worked).<div class="codebox"><p>Code: </p><pre><code>addjss</code></pre></div><div class="codebox"><p>Code: </p><pre><code>proc addjss {  } {global canal_adminif {![file exists djnick]} { return }set fname0 "djnick"set fp [open $fname0 "r"]set data [read -nonewline $fp]close $fpset lines [split $data " "]set addjs [lindex $lines 0]set datehour [lrange $lines 3 end]if {![file exists listaDJS]} {set fs [open listaDJS "w"]puts $fs ""close $fs} else {set now [clock seconds]set then [clock scan $datehour -format " %A %d de %B a las %H:%M:%S"]if {[expr $now - $then] &gt; 14400 } { set fname "listaDJS"set fp [open $fname "a"] puts $fp "$addjs $datehour"close $fp } else { putquick "PRIVMSG $canal_admin :this issue is not stored";return }}}</code></pre></div>Of the two ways gave me the same error:<br><strong class="text-strong">Tcl error [pub_setdj]: input string does not match supplied format</strong><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Mon Sep 12, 2016 12:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-12T10:06:04-04:00</updated>

		<published>2016-09-12T10:06:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105423#p105423</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105423#p105423"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105423#p105423"><![CDATA[
<blockquote class="uncited"><div>...<br>The variable that gives me trouble to compare is:<div class="codebox"><p>Code: </p><pre><code>set hespad [clock format [clock scan "0 day" -base [clock seconds]] -format " %A %d de %B a las %H:%M:%S"] </code></pre></div>...</div></blockquote>You want to compare the time stored in $hespad to the current time, correct?<br><br>But the value stored in $hespad is in text.  So you need to convert the time stored in text in $hespad, to a numerical value so you can do math on it to compare it to the current time.   Is this correct?<br><br>( I may have done this differently, by storing the original numerical time value... rather than convert back and forth.... but no matter )<br><br>Try this command:<div class="codebox"><p>Code: </p><pre><code>clock scan $hespad -format " %A %d de %B a las %H:%M:%S"</code></pre></div>I tried it and it works.  It returns a number.   If you want to see what that number represents, then do:<div class="codebox"><p>Code: </p><pre><code> ctime [clock scan $hespad -format " %A %d de %B a las %H:%M:%S"]</code></pre></div>And you already know that<br>[clock seconds]<br>returns a number that represents the current time.<br><br>Four hours is 14400 seconds.<br><br>So something like:<div class="codebox"><p>Code: </p><pre><code>set now [clock seconds]set then [clock scan $hespad -format " %A %d de %B a las %H:%M:%S"]if {[expr $now - $then] &gt; 14400 } {       puts $fp "$addjs $datehour"     }</code></pre></div>might do what you want.<br><br>I think I've got the picture now.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Mon Sep 12, 2016 10:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-12T09:14:56-04:00</updated>

		<published>2016-09-12T09:14:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105421#p105421</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105421#p105421"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105421#p105421"><![CDATA[
<blockquote class="uncited"><div>Just get the difference compared to current time, and if it is less than four hours, don't save new info.</div></blockquote>The question I have is like comparing it the same nickname and corresponding to the same day , with the difference of 4 hours .  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"> <br>This comparison have to do at the time that the database is formed , not in that extract data.<br><br>The variable that gives me trouble to compare is:<div class="codebox"><p>Code: </p><pre><code>set hespad [clock format [clock scan "0 day" -base [clock seconds]] -format " %A %d de %B a las %H:%M:%S"] </code></pre></div><blockquote class="uncited"><div>proc addjss { } {<br>global canal_admin<br>   if {![file exists djnick]} { return }<br>      set fname0 "djnick"<br>      set fp [open $fname0 "r"]<br>      set data [read -nonewline $fp]<br>      close $fp<br>      set lines [split $data " "] <br>      set addjs [lindex $lines 0]<br>      set datehour [lrange $lines 3 end]<br> <br>   if {![file exists listaDJS]} {<br>      set fs [open listaDJS "w"]<br>      puts $fs ""<br>      close $fs<br>   }  else {<br>   set fname "listaDJS"<br>   set fp [open $fname "a"]<br><span style="color:red"><strong class="text-strong">COMPARISON would go here</strong></span><br>   puts $fp "$addjs $datehour"<br>   close $fp<br>   }<br>}</div></blockquote>Can you help me with the line that I'm missing ?  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Mon Sep 12, 2016 9:14 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-11T16:01:21-04:00</updated>

		<published>2016-09-11T16:01:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105419#p105419</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105419#p105419"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105419#p105419"><![CDATA[
<blockquote class="uncited"><div><br>...<br>This data <blockquote class="uncited"><div>1473590937</div></blockquote> represents the time that culminated issue Juan.<br>I use it to perform mathematical operations<br><br>...</div></blockquote>Then you are all set.  <br>You have the time saved.   Just get the difference compared to current time, and if it is less than four hours, don't save new info.<br><br>What you have described is something very similar to what I was thinking of.<br><br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Good luck with it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Sep 11, 2016 4:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-11T15:20:42-04:00</updated>

		<published>2016-09-11T15:20:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105418#p105418</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105418#p105418"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105418#p105418"><![CDATA[
<blockquote class="uncited"><div>...<br>I was wondering about how lines like this are created:<br>Juan Miércoles 7 de Setiembre a las 04:06:38 <br>....</div></blockquote>I do not like long explanations, because my English is very bad.<br>But I will try... <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>There are several databases (files).<br>When a DJ goes up to emission, its nick and start time is stored in this way:<div class="codebox"><p>Code: </p><pre><code>set horadjstart [clock seconds]set temp [open "dj" w+]puts $temp "$djnickname $horadjstart"close $temp </code></pre></div>When the DJ ends its emission, the values are stored in another file:<div class="codebox"><p>Code: </p><pre><code>set horadjend [clock seconds]set hespad [clock format [clock scan "0 day" -base [clock seconds]] -format " %A %d de %B a las %H:%M:%S"]set temp [open "djnick" w+]puts $temp "$bajardj $horadjend $hespad"close $temp</code></pre></div>bajardj variable == DJ Nick has completed its issuance (emission)<br>horadjend variable == time of DJ used the command to get off emission<br>hespad variable == end time with clock format<br><br>As you have seen in previous post, listaDJs data base is formed with the nick of  DJ and the time they ended broadcasting (emission).<br>These data are extracted from the "djnick" file.<br>In this file only the last DJ issued is stored and the final time of his emission.<br>When a new DJ goes  up to emission, and he ends, the "djnick" file is deleted and a new file "djnick" is created with the name of this last DJ and the time off end the emission.<br><br>This is the current contents of the "djnick" file:<blockquote class="uncited"><div>Juan 1473590937  Domingo 11 de Setiembre a las 12:48:57</div></blockquote>This data <blockquote class="uncited"><div>1473590937</div></blockquote> represents the time that culminated issue Juan.<br>I use it to perform mathematical operations<br><br><br>I'm so sorry for the quantity of data I'm given to you.<br>I understand is difficult without haven't seen the full script.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Sun Sep 11, 2016 3:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-11T14:24:47-04:00</updated>

		<published>2016-09-11T14:24:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105417#p105417</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105417#p105417"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105417#p105417"><![CDATA[
<blockquote class="uncited"><div>...<br>I understand.<br>It is that the entire scropt has more than 10 thousand lines .</div></blockquote>That's huge.<br><br>They all cannot apply to this one issue.<br>Post all the lines that do.<br><blockquote class="uncited"><div>My idea was to include the conditional when the database ( listaDJS file) is modified.<br>...</div></blockquote>I was wondering about how lines like this are created:<blockquote class="uncited"><div>Juan Miércoles 7 de Setiembre a las 04:06:38 </div></blockquote>suspecting that something like [unixtime] command is used to get the current time, at that time.<br>Then something else comes along and uses that to create what is saved in the file.<br>With that original [unixtime], you could do some math and conditional checking.<br>Perhaps you could have the script save that original [unixtime].  That would make it easier.<br><br>If you must work with it, exactly as quoted above, then here is something to experiment with:<div class="codebox"><p>Code: </p><pre><code>clock scan [lindex [split "7 de Setiembre a las 04:06:38" ] end ] -format %H:%M:%S</code></pre></div>and<div class="codebox"><p>Code: </p><pre><code>ctime [clock scan [lindex [split "7 de Setiembre a las 04:06:38" ] end ] -format %H:%M:%S ]</code></pre></div>(so you can see what is actually returned)<br><br>I'm not very good with the <br>clock<br>command.  I don't know how to deal with it, in various languages.<br><a href="http://www.tcl.tk/man/tcl8.6/TclCmd/clock.htm" class="postlink">http://www.tcl.tk/man/tcl8.6/TclCmd/clock.htm</a><br><br>Perhaps someone else will jump in here, with better ideas for you.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Sep 11, 2016 2:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-11T14:06:47-04:00</updated>

		<published>2016-09-11T14:06:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105416#p105416</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105416#p105416"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105416#p105416"><![CDATA[
<blockquote class="uncited"><div>....<br>But trying to do this without seeing the -COMPLETE- script might be a waste of time.<br>....</div></blockquote>I understand.<br>It is that the entire scropt has more than 10 thousand lines .<br>My idea was to include the conditional when the database ( listaDJS file) is modified.<br>I'll see what I can fix like .<br>Thank you very much for your kind help.  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Sun Sep 11, 2016 2:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-11T13:32:26-04:00</updated>

		<published>2016-09-11T13:32:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105415#p105415</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105415#p105415"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105415#p105415"><![CDATA[
<blockquote class="uncited"><div>...<br>I edited post, please see it  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"></div></blockquote><br>There might be a few ways to accomplish it.<br>It sounds like you need to do some math with time measurements.<br><br>But trying to do this without seeing the -COMPLETE- script might be a waste of time.<br><br>Please either post the script here in this thread, or<br><a href="http://paste.tclhelp.net/" class="postlink">http://paste.tclhelp.net/</a><br>whichever suits you best.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Sep 11, 2016 1:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-11T12:02:26-04:00</updated>

		<published>2016-09-11T12:02:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105414#p105414</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105414#p105414"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105414#p105414"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>....<br> it worked perfect!  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"></div></blockquote>Good to hear !    <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br><br>You're welcome.</div></blockquote>I edited post, please see it  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Sun Sep 11, 2016 12:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-11T11:38:50-04:00</updated>

		<published>2016-09-11T11:38:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105413#p105413</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105413#p105413"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105413#p105413"><![CDATA[
<blockquote class="uncited"><div>....<br> it worked perfect!  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"></div></blockquote>Good to hear !    <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br><br>You're welcome.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Sep 11, 2016 11:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-11T12:01:08-04:00</updated>

		<published>2016-09-11T11:31:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105412#p105412</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105412#p105412"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105412#p105412"><![CDATA[
Thanks for the help of <strong class="text-strong">willyw</strong>.<br>In the end I decided for the <strong class="text-strong"><span style="color:blue">for</span></strong> command.<div class="codebox"><p>Code: </p><pre><code>for {set i 0} {$i &lt; [llength $data]} {incr i} {putquick "PRIVMSG $canal_admin :[lindex $data $i]"}</code></pre></div>Before , I modified what was wrong ($fname) and I used <strong class="text-strong"><span style="color:blue">lreverse</span></strong>, did not know that command.<div class="codebox"><p>Code: </p><pre><code>set fp [open listaDJS "w"]      puts $fp [join $data "\n"]      close $fp      }     set data1 [split $data "\n"]  set data [lreverse $data1] </code></pre></div>Thanks for the ideas, it worked perfect!  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><br><strong class="text-strong">Turning to another matter ...</strong><br><br>The list contains two items (DJ and date-hour).<br>I wish not to allow stored emissions of the same DJ to get together if they have not yet passed 4 hours of its previous issues.<br><br><span style="text-decoration:underline">EXAMPLE</span>:<br>John issued at 00 hours and do it again to 01:30 a.m. .<br>What I want is  the bot does not store this information for 01:30 a.m. .<br>I want to prevent the same DJ climb to broadcast many times in a short space of time, to have a greater number of emissions covered.<br>If the same DJ reissues, I wish to save the data only if it has been 4 hours of their previous issue .<br><br>The database is formed this way:<div class="codebox"><p>Code: </p><pre><code>proc addjss { } {global canal_adminif {![file exists djnick]} { return }set fname0 "djnick"set fp [open $fname0 "r"]set data [read -nonewline $fp]close $fpset lines [split $data " "]  set addjs [lindex $lines 0]set datehour [lrange $lines 3 end] if {![file exists listaDJS]} {set fs [open listaDJS "w"]puts $fs ""close $fs}  else {set fname "listaDJS"set fp [open $fname "a"]puts $fp "$addjs $datehour"close $fp }}</code></pre></div>The variable <strong class="text-strong"><span style="color:green">addjs</span></strong> keep nick <strong class="text-strong"><span style="color:green">DJ</span></strong> and the variable <strong class="text-strong"><span style="color:orange">datehour</span> </strong>saves the <strong class="text-strong"><span style="color:orange">date and time</span></strong> of issue.<br>Something like that:<div class="codebox"><p>Code: </p><pre><code>if {($addjs == "previous DJ") &amp;&amp; ([expr { [clock seconds] - $your previous DJ time}] &lt; "4 hours")} { return }else {puts $fp "$addjs $datehour"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Sun Sep 11, 2016 11:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2016-09-10T18:14:42-04:00</updated>

		<published>2016-09-10T18:14:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105411#p105411</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105411#p105411"/>
		<title type="html"><![CDATA[Re: What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105411#p105411"><![CDATA[
This line should be generating an error:<div class="codebox"><p>Code: </p><pre><code>set fp [open $fname "w"] </code></pre></div>because the varialbe $fname has never been set.<br><br>I have not tried to run your code at all.  But the <br>while <br>loop looks to me like it will just go forever, as you said.<br>That's because:<div class="codebox"><p>Code: </p><pre><code>while {[llength $data] &gt; 0} { </code></pre></div>there is nothing to shorten the length of $data.  It will always be greater than 0.<br><br>If it were me, I wouldn't use a while loop anyway, if possible.<br>See if you can use a <br>foreach<br>loop.     <a href="http://www.tcl.tk/man/tcl8.6/TclCmd/foreach.htm" class="postlink">http://www.tcl.tk/man/tcl8.6/TclCmd/foreach.htm</a><br><br>While you are there, at the TCL site,  check out:<br><a href="http://www.tcl.tk/man/tcl8.6/TclCmd/lreverse.htm" class="postlink">http://www.tcl.tk/man/tcl8.6/TclCmd/lreverse.htm</a><br>as it might do what you want, for outputting the lines, last to first.<br><br>I hope this helps.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sat Sep 10, 2016 6:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2016-09-10T17:33:18-04:00</updated>

		<published>2016-09-10T17:33:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105410#p105410</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105410#p105410"/>
		<title type="html"><![CDATA[What is wrong in the loop ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105410#p105410"><![CDATA[
The file (listaDJS) contains the name, date and time of transmission (broadcast ) of my Radio DJs.<br>Example lines files:<blockquote class="uncited"><div>Juan Miércoles 7 de Setiembre a las 04:06:38<br>Pedro Jueves 8 de Setiembre a las 05:08:54<br>Maria Viernes 9 de Setiembre a las 15:11:49<br>Jack Viernes 9 de Setiembre a las 16:50:42<br>Axel Viernes 9 de Setiembre a las 18:22:02</div></blockquote>When you run it seems that the bot is in an infinite loop.<br>I want to solve this bug .<br>In addition , I wish to show me the list in reverse order to what the show now .<br>I wish that first show last broadcast date and time.<blockquote class="uncited"><div>Axel Viernes 9 de Setiembre a las 18:22:02<br>Jack Viernes 9 de Setiembre a las 16:50:42<br>Maria Viernes 9 de Setiembre a las 15:11:49<br>Pedro Jueves 8 de Setiembre a las 05:08:54<br>Juan Miércoles 7 de Setiembre a las 04:06:38</div></blockquote>Today I list the order of emissions , in the order they are lines.<br><strong class="text-strong">The code</strong>:<div class="codebox"><p>Code: </p><pre><code>proc pub:brodcasting {nick uhost hand chan text} {global canal_adminif { $chan == $canal_admin } {if {[file exist listaDJS]} {         set file [open listaDJS "r"] set data [read $file] set first [lindex $data 0]if {$first == ""} {set line_to_delete 0 set data [lreplace $data $line_to_delete $line_to_delete]  set fp [open $fname "w"]puts $fp [join $data "\n"]close $fp} set data [split $data "\n"]         set x 0          while {[llength $data] &gt; 0} {      if {([llength $data] == 0) &amp;&amp; ($x == 0)} { putquick "PRIVMSG $canal_admin :The list is empty."; return }               if {$data == ""} { continue }    putquick "PRIVMSG $canal_admin :\0032Dj \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011  Date \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011 \011\011 \011 \011 \011 \011 \011 \011 \011 \011   Time"  putquick "PRIVMSG $canal_admin :[lindex $data $x]"                  set x [expr {$x + 1}]}         close $file putquick "PRIVMSG $canal_admin :\0032____End of List____"    } else {    putmsg $canal_admin "Data Base is missing!"    } } else {return}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Sat Sep 10, 2016 5:33 pm</p><hr />
]]></content>
	</entry>
	</feed>
