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

	<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-09-29T10:24:41-04:00</updated>

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

		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-09-29T10:24:41-04:00</updated>

		<published>2009-09-29T10:24:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90399#p90399</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90399#p90399"/>
		<title type="html"><![CDATA[Commands]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90399#p90399"><![CDATA[
It is quite common to find several ways to accomplish the exact same thing. This would be true to some degree of any programming/scripting language.<br><br>However, not wishing to seem a bore, I do get the impression that you are not taking in what I am trying to communicate regarding the difference between strings and string lists.<br><br>A better understanding of these data structures can save you many problems in the future, though I can say that I do still make such mistakes (such is the ease with which they sometimes get confused).<br><br>Taking your latest code example apart :-<br><div class="codebox"><p>Code: </p><pre><code>set text [split $text]</code></pre></div>Although it cannot be confirmed by simply looking at the statement above, it does give the impression that the original value of the variable text is a string, because it is being split to form a list. The set command overwrites the original string value of text with the list value. Given that it is now a list, you can safely use list commands such as lrange on it :-<br><div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]</code></pre></div>Indices for lrange (and other commands) start at zero, so the above statement makes a new list from the 3rd element onwards of text and again overwrites the value of text with this new list. It is STILL a list.<br><div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]set text "$text :requested by $nick"</code></pre></div>This is potentially where things could all go pear shaped. The second statement may well succeed on occasions in generating what you need, yet it does create something that may not have been anticipated. The new list value of text has had string characters attached to it.<br><br>There are really two ways to go. Firstly if you want to end up with a normal string :-<br><div class="codebox"><p>Code: </p><pre><code>set text [join [lrange [split $text] 2 end]]set text "$text :requested by $nick"</code></pre></div>This is probably the best because it ensures that the value of text is in the same form as it was in the first place. The join command has been used in the first statement to convert the lrange result back into a string. Hence, the second statement simply adds additional characters to form a longer string.<br><br>The join command could be alternatively placed as follows :-<br><div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]set text "[join $text] :requested by $nick"</code></pre></div>Secondly, If you definitely need the result to be a list, then you first need to determine if the three words included in ':requested by $nick' are to be three distinct list elements or one single list element. These are the two possibilities :-<br><div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]lappend text :requested by $nick</code></pre></div><div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]lappend text ":requested by $nick"</code></pre></div>In reality the problem can get rather more complicated because lists of list and lists of lists of lists etc etc are permitted. That means that the join command wouldn't necessarily create a string. It may create a 'flatter' list. To be fair I would forget this added difficulty until you are confident with the simple case (a normal string OR a flat list of string elements).<br><br>Some insight into the sort of problems that can occur can be gained by reading :-<br><br><a href="http://www.peterre.info/characters.html" class="postlink">http://www.peterre.info/characters.html</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Tue Sep 29, 2009 10:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[NoZparker]]></name></author>
		<updated>2009-09-28T22:42:17-04:00</updated>

		<published>2009-09-28T22:42:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90395#p90395</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90395#p90395"/>
		<title type="html"><![CDATA[Commands]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90395#p90395"><![CDATA[
whilst reading the url <a href="http://eggdrop.org.ru/data/man/sunnet/index.html" class="postlink">http://eggdrop.org.ru/data/man/sunnet/index.html</a> <br><br><br>i've found another method (so easy)<div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]set text "$text :requested by $nick"</code></pre></div>seems like one minute nothing works, the next minute three options work<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4570">NoZparker</a> — Mon Sep 28, 2009 10:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-09-28T22:31:02-04:00</updated>

		<published>2009-09-28T22:31:02-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90394#p90394</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90394#p90394"/>
		<title type="html"><![CDATA[Commands]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90394#p90394"><![CDATA[
Yes, that would work fine.<br><br>However, be careful. In your code, the variable text started life as a string but it is now a list.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Mon Sep 28, 2009 10:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[NoZparker]]></name></author>
		<updated>2009-09-28T22:12:17-04:00</updated>

		<published>2009-09-28T22:12:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90392#p90392</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90392#p90392"/>
		<title type="html"><![CDATA[How to add text to a line of text]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90392#p90392"><![CDATA[
many thanks for your quick reply<br><div class="codebox"><p>Code: </p><pre><code>set text "[join [lrange [split $text] 2 end]] requested by $nick"</code></pre></div>does work<br><br>I have also found that <div class="codebox"><p>Code: </p><pre><code>set text [lrange [split $text] 2 end]lappend text :Requested by $nick</code></pre></div>also works<br>found that merged with other stuff in "tip of the day"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4570">NoZparker</a> — Mon Sep 28, 2009 10:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-09-28T21:55:54-04:00</updated>

		<published>2009-09-28T21:55:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90391#p90391</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90391#p90391"/>
		<title type="html"><![CDATA[Commands]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90391#p90391"><![CDATA[
This thread probably belongs in the 'Scripting Help' forum<br><br>Core Tcl 8.4<br><br><a href="http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm" class="postlink">http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm</a><br><br>Core Tcl 8.5<br><br><a href="http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm" class="postlink">http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm</a><br><br>Eggdrop 1.6.19 Tcl<br><br><a href="http://www.eggheads.org/support/egghtml/1.6.19/tcl-commands.html" class="postlink">http://www.eggheads.org/support/egghtml ... mands.html</a><br><br>Basic Eggdrop Tcl Tutorial<br><br><a href="http://eggdrop.org.ru/data/man/sunnet/index.html" class="postlink">http://eggdrop.org.ru/data/man/sunnet/index.html</a><br><br><br>Your string concatenation could be very simply written :-<br><div class="codebox"><p>Code: </p><pre><code>set text "[join [lrange [split $text] 2 end]] requested by $nick"</code></pre></div>The statement would be first parsed to make the command and variable substitutions before assigning the result to the variable text.<br><br>Exact syntax above assumes you wanted a space between the two components. Note the addition of a 'join' command to convert back to a string.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Mon Sep 28, 2009 9:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[NoZparker]]></name></author>
		<updated>2009-09-28T20:06:01-04:00</updated>

		<published>2009-09-28T20:06:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90390#p90390</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90390#p90390"/>
		<title type="html"><![CDATA[Commands]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90390#p90390"><![CDATA[
Where can i find a list of ALL commands and the correct syntax used in a tcl<br>for example:-<br>lindex<br>lrange<br>lreplace<br>and how to add a line of text to a line of text<br>eg, <br>set text [lrange [split $text] 2 end] + "requested by $nick"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4570">NoZparker</a> — Mon Sep 28, 2009 8:06 pm</p><hr />
]]></content>
	</entry>
	</feed>
