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

	<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>2003-08-02T05:13:57-04:00</updated>

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

		<entry>
		<author><name><![CDATA[arcane]]></name></author>
		<updated>2003-08-02T05:13:57-04:00</updated>

		<published>2003-08-02T05:13:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=24268#p24268</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=24268#p24268"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=24268#p24268"><![CDATA[
hm... maybe you have some function for me, too <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>i've got the following arrays<div class="codebox"><p>Code: </p><pre><code>array(chan1,1,var1) "var1"array(chan1,1,var2) "var2"array(chan1,2,var1) "var3"array(chan1,2,var2) "var4"array(chan1,3,var1) "var5"array(chan1,3,var2) "var6"...</code></pre></div>and so on.<br><br>i unset all arrays chan1,2 using<div class="codebox"><p>Code: </p><pre><code>array unset array chan1,2,*</code></pre></div>now i'd need a proc that "refills" the array. means, array(chan1,3,var1)<br>should become array(chan1,2,var1), array(chan1,4,var1) should become<br>array(chan1,3,var1). hope you see my point.<br><br>guess i'd just have to change some code in the array_push proc of ppslim,<br>but, however, i don't know what it does exactly.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2617">arcane</a> — Sat Aug 02, 2003 5:13 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-07-24T14:11:42-04:00</updated>

		<published>2003-07-24T14:11:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23904#p23904</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23904#p23904"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23904#p23904"><![CDATA[
<blockquote class="uncited"><div>seams noone has an idea what i am talking about <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"></div></blockquote>I think I do. Tcl's "arrays" are not suited for this kind of task. Use a list.<br><br>To add one element to the start of a list and keep the number of elements below a given value, use something like this:<div class="codebox"><p>Code: </p><pre><code>set list [concat [list $new] [lrange $list 0 2]]</code></pre></div>or<div class="codebox"><p>Code: </p><pre><code>set list [lrange [concat [list $new] $list] 0 3]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Thu Jul 24, 2003 2:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[GodOfSuicide]]></name></author>
		<updated>2003-07-24T13:38:55-04:00</updated>

		<published>2003-07-24T13:38:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23902#p23902</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23902#p23902"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23902#p23902"><![CDATA[
seams noone has an idea what i am talking about <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1433">GodOfSuicide</a> — Thu Jul 24, 2003 1:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[GodOfSuicide]]></name></author>
		<updated>2003-07-22T13:08:24-04:00</updated>

		<published>2003-07-22T13:08:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23791#p23791</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23791#p23791"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23791#p23791"><![CDATA[
i was meaning an other thing<br><br>The old parsed data (lets say 4 arrayelements) is compared to the new parsed data (also 4 elements).<br><br>old :<blockquote class="uncited"><div>news 123 (url : 123)<br>news 234 (url : 234)<br>news 345 (url : 345)<br>news 456 (url : 456)</div></blockquote>new : <blockquote class="uncited"><div>news abc (url : abc)<br>news bcd (url : bcd)<br>news 123 (url : 123)<br>news 234 (url : 234)</div></blockquote>right now there were 2 new data sets in NEW that haven't been in OLD befor. Now i want to output these 2 new entrys and then write the content of NEW -&gt; OLD so i can check again the next time if there have been new sets.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1433">GodOfSuicide</a> — Tue Jul 22, 2003 1:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-07-22T05:58:31-04:00</updated>

		<published>2003-07-22T05:58:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23779#p23779</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23779#p23779"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23779#p23779"><![CDATA[
This would require two small function to perform this. One to push the array, and another to trim it again.<br><br>First note: Tcl claims these are arrays. This is not true, they are actualy "Hash tables".<br><br>The code below will push an ellement onto the start of the array.<div class="codebox"><p>Code: </p><pre><code>proc array_push {name data} {  array set temp [list]  upvar 1 $name this  foreach idx [array names this] {    set temp([expr $idx + 1]) $this($idx)  }  set temp(0) $data  array set this [array get temp]}</code></pre></div>Use it like this<div class="codebox"><p>Code: </p><pre><code>set array(0) "test value"set array(1) "another value"set array(2) "More data"array_push array "some more data again"</code></pre></div>The code below, will trim the array down to X elements<div class="codebox"><p>Code: </p><pre><code>proc array_trim {name X} {  upvar 1 $name this  set list [lsort -integer [array names this]]  set limit [expr [llength $list] - ( $X + 1 )]  if {$limit &lt; 0} { return }  foreach a [lrange $list "end-${limit}" end] {    array unset this $a  }}</code></pre></div>Test it with the following<div class="codebox"><p>Code: </p><pre><code>set array(0) "test value"set array(1) "another value"set array(2) "More data"set array(3) "More data 123"set array(4) "More data 456"set array(5) "More data 789"set array(6) "More data 741"set array(7) "More data 852"array_trim array 5</code></pre></div>Here is the results of the tests above, using this small snippet.<div class="codebox"><p>Code: </p><pre><code>foreach {a b} [array get array] {  puts stdout "${a}: ${b}"}</code></pre></div>array_push<blockquote class="uncited"><div>0: some more data again<br>1: test value<br>2: another value<br>3: More data</div></blockquote>array_trim<blockquote class="uncited"><div>4: More data 456<br>0: test value<br>1: another value<br>2: More data<br>3: More data 123</div></blockquote>Note: The order of output is not important. As ntoed, they are hash lists, and will never be in order. To get ordered info, use a sorted foreach loop<br><div class="codebox"><p>Code: </p><pre><code>foreach array_idx [lsort -integer [array names array_name]] {</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Jul 22, 2003 5:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[GodOfSuicide]]></name></author>
		<updated>2003-07-22T01:58:18-04:00</updated>

		<published>2003-07-22T01:58:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23775#p23775</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23775#p23775"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23775#p23775"><![CDATA[
there is a maximum of y fields in the array (if the page only links the latest y news, etc)<br><br>on z new posts the post that was first (0) befor is now on 0+z position, and the last z ones are now gone<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1433">GodOfSuicide</a> — Tue Jul 22, 2003 1:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-07-21T20:01:17-04:00</updated>

		<published>2003-07-21T20:01:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23768#p23768</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23768#p23768"/>
		<title type="html"><![CDATA[Re: Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23768#p23768"><![CDATA[
<blockquote class="uncited"><div>if there have been x new entrys on the page the array shifts down by x entrys<br>but : how do i check for this data and make a loop for the output ?</div></blockquote>What do you mean by "the array SHIFTS down by x entrys"?<br><br>If you store the last post and have a list of current posts, just check how many elements are before/after (depending on the order) the element matching the 'last post' value.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Mon Jul 21, 2003 8:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[GodOfSuicide]]></name></author>
		<updated>2003-07-21T14:04:32-04:00</updated>

		<published>2003-07-21T14:04:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=23754#p23754</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=23754#p23754"/>
		<title type="html"><![CDATA[Arrays and differences]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=23754#p23754"><![CDATA[
I'm currently rewriting all of my newstickers<br><br>until now i used some kinda code like this (written just to show what i mean):<div class="codebox"><p>Code: </p><pre><code>if {$site_data(0) != $site_newdata(0)} {putserv "PRIVMSG #chan :$site_newdata(0)" set site_data(0) $site_newdata(0)}</code></pre></div>Now i would like to do it another way :<br>if there have been x new entrys on the page the array shifts down by x entrys<br>but : how do i check for this data and make a loop for the output ?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1433">GodOfSuicide</a> — Mon Jul 21, 2003 2:04 pm</p><hr />
]]></content>
	</entry>
	</feed>
