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

	<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>2008-02-04T13:12:42-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2008-02-04T13:12:42-04:00</updated>

		<published>2008-02-04T13:12:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=80637#p80637</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=80637#p80637"/>
		<title type="html"><![CDATA[Weird behavior of FOREACH command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=80637#p80637"><![CDATA[
and stop using list commands on strings.<br>split the sting into a var and then<br>use the foreach  .... <br><br>global botnick<br>if the botnick var was not called then it will produce <br>an error and stop the loop<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Mon Feb 04, 2008 1:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2007-12-09T17:57:56-04:00</updated>

		<published>2007-12-09T17:57:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=79167#p79167</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=79167#p79167"/>
		<title type="html"><![CDATA[Weird behavior of FOREACH command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=79167#p79167"><![CDATA[
@nml375: I know the way I use is not really good, but it works.<br><br>@z_one: the second example I gave is working because it use the logical way to transform a string into a list.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Sun Dec 09, 2007 5:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[z_one]]></name></author>
		<updated>2007-12-09T16:13:08-04:00</updated>

		<published>2007-12-09T16:13:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=79161#p79161</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=79161#p79161"/>
		<title type="html"><![CDATA[Weird behavior of FOREACH command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=79161#p79161"><![CDATA[
Yeah, sorry about that botnick thing ... I forgot to copy it here as I was typing the code manually.<br><br>So basically, nml375, if I use the list-command I can use any of the following ?<div class="codebox"><p>Code: </p><pre><code>set thechanlist [list #chanA #chanB #chanC]</code></pre></div>OR<div class="codebox"><p>Code: </p><pre><code>set thechanlist [list "#chanA" "#chanB" "#chanC"]</code></pre></div>OR<div class="codebox"><p>Code: </p><pre><code>set thechanlist [list {#chanA} {#chanB} {#chanC}]</code></pre></div>I think Crazycat's second example should work too because the split-command would turn the string <strong class="text-strong">"#chanA #chanB #chanC"</strong> into a list right ?<br><br>Thank you both for the replies.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=698">z_one</a> — Sun Dec 09, 2007 4:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-12-09T13:07:41-04:00</updated>

		<published>2007-12-09T13:07:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=79153#p79153</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=79153#p79153"/>
		<title type="html"><![CDATA[Weird behavior of FOREACH command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=79153#p79153"><![CDATA[
@CrazyCat:<div class="codebox"><p>Code: </p><pre><code>{"#chanA" "#chanB" "#chanC"}</code></pre></div>This is just as much a string as the code used by z_one..<br>To make proper list, use the list-command (or split).<br>Ie:<div class="codebox"><p>Code: </p><pre><code>set thechanlist [list #chanA "#chanB" {#chanC}]</code></pre></div>@z_one:<br>If you use the global-command to link a localspace variable to the globalspace one, you don't need to use full namespace paths for that variable. In the same way, if you use full namespace path, there is no reason to use "global". Nothing wrong with doing both I guess, except that you might forget that the localspace variable is linked to the globalspace in larger scripts.<br><br>I do however notice that you try to access the globalspace variable botnick as a localspace variable without using "global". This should cause an error, and prematurely abort the proc with an error condition.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Dec 09, 2007 1:07 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2007-12-09T07:10:59-04:00</updated>

		<published>2007-12-09T07:10:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=79141#p79141</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=79141#p79141"/>
		<title type="html"><![CDATA[Weird behavior of FOREACH command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=79141#p79141"><![CDATA[
You set a string, not a list or array.<br>You can use:<div class="codebox"><p>Code: </p><pre><code># list of channelsset thechanlist {"#chanA" "#chanB" "#chanC"}proc whereisthebot {} {  foreach chan $::thechanlist {    if {[botonchan $chan]} {      putlog "$botnick is on $chan"    }  }}</code></pre></div>Or if you want to keep your initial setting:<div class="codebox"><p>Code: </p><pre><code># list of channelsset thechanlist "#chanA #chanB #chanC"proc whereisthebot {} {  foreach chan [split $::thechanlist " "] {    if {[botonchan $chan]} {      putlog "$botnick is on $chan"    }  }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Sun Dec 09, 2007 7:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[z_one]]></name></author>
		<updated>2007-12-09T02:41:01-04:00</updated>

		<published>2007-12-09T02:41:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=79135#p79135</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=79135#p79135"/>
		<title type="html"><![CDATA[Weird behavior of FOREACH command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=79135#p79135"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code># list of channels set thechanlist "#chanA #chanB #chanC" proc whereisthebot {} {   global thechanlist  foreach chan $::thechanlist {     if {[botonchan $chan]} {       putlog "$botnick is on $chan"     }   } } </code></pre></div>Then in the bot .conf file I have added ChanA, ChanB and ChanC in this exact order. The script works fine.<br><br>Now, whenever I set the variable <strong class="text-strong">thechanlist</strong> to "#chanC #chanA #chanB" for example ... then the foreach loop just goes over ChanC and doesn't go over the two other chans.<br><br>I don't get it. What does the variable <strong class="text-strong">thechanlist</strong> have to do with the bot's .conf file ?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=698">z_one</a> — Sun Dec 09, 2007 2:41 am</p><hr />
]]></content>
	</entry>
	</feed>
