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

	<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>2009-05-21T15:03:53-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-05-21T15:03:53-04:00</updated>

		<published>2009-05-21T15:03:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88857#p88857</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88857#p88857"/>
		<title type="html"><![CDATA[[SOLVED] split at given position and repeat]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88857#p88857"><![CDATA[
The first example would work just fine for any valid tcl-list, irregardless of length. The only "kink" would be that the "value-less" iteration variables would contain "" in the last loop iteration..<div class="codebox"><p>Code: </p><pre><code>% set thelist [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23]% foreach [list a b c d e f g h] $thelist { puts stdout "PRIVMSG #thechannel :$a $b $c $d $e $f $g $h"}PRIVMSG #thechannel :1 2 3 4 5 6 7 8PRIVMSG #thechannel :9 10 11 12 13 14 15 16PRIVMSG #thechannel :17 18 19 20 21 22 23</code></pre></div>Compared to:<div class="codebox"><p>Code: </p><pre><code>% set thelist [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23]% set len [llength $thelist]% set i 0% while {$i &lt; $len} {  puts stdout "PRIVMSG #thechannel :[lrange $thelist $i [incr i 8]]"}PRIVMSG #thechannel :1 2 3 4 5 6 7 8 9PRIVMSG #thechannel :9 10 11 12 13 14 15 16 17PRIVMSG #thechannel :17 18 19 20 21 22 23</code></pre></div>Notice how both examples handle the last iteration just fine, despite being only 7 items left in the list. Which way to go, mainly depends on whether you need to access each list item separately, or as a block, within the loop body.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu May 21, 2009 3:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2009-05-21T14:49:19-04:00</updated>

		<published>2009-05-21T14:49:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88856#p88856</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88856#p88856"/>
		<title type="html"><![CDATA[[SOLVED] split at given position and repeat]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88856#p88856"><![CDATA[
lets try example 2 of yours since example one looks nice but wouldnt be working with a list containing a different number of objects everytime<br><br>edit:<br><br>you are a genius nml375 :&gt;<br>thanks for helping again <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=9589">raider2k</a> — Thu May 21, 2009 2:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-05-21T14:37:48-04:00</updated>

		<published>2009-05-21T14:37:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88853#p88853</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88853#p88853"/>
		<title type="html"><![CDATA[[SOLVED] split at given position and repeat]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88853#p88853"><![CDATA[
I'd probably do it something like this:<div class="codebox"><p>Code: </p><pre><code>foreach [list a b c d e f g h] $thelist { puthelp "PRIVMSG #thechannel :$a $b $c $d $e $f $g $h"}</code></pre></div>Other options would be using lrange, such as:<div class="codebox"><p>Code: </p><pre><code>set len [llength $thelist]set i 0while {$i &lt; $len} { puthelp "PRIVMSG #thechannel :[join [lrange $thelist $i [incr i 7]]]" incr i}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu May 21, 2009 2:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2009-05-21T14:58:33-04:00</updated>

		<published>2009-05-21T14:01:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88850#p88850</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88850#p88850"/>
		<title type="html"><![CDATA[[SOLVED] split at given position and repeat]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88850#p88850"><![CDATA[
subject this time:<br><br>a list, containing different number of objects everytime<br>want it to be split after (in example) 8 objects, output those first 8 objects to channel and repeat that step for the next 8 objects until all the objects have been sent to channel.<br><br>example:<br><br>list contains: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24<br><br>how i want it to output in channel:<br>numbers: 1 2 3 4 5 6 7 8<br>numbers: 9 10 11 12 13 14 15 16<br>numbers: 17 18 19 20 21 22 23 24<br><br>i came across this one today<br><br><a href="http://forum.egghelp.org/viewtopic.php?t=11522" class="postlink">http://forum.egghelp.org/viewtopic.php?t=11522</a><br><br>while searching the forum but it splits by using a given string length, so its not what helps me working with a list. also tried to understand the code and maybe change it to my needs but im totally lost and need help please to be honest.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Thu May 21, 2009 2:01 pm</p><hr />
]]></content>
	</entry>
	</feed>
