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

	<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-22T15:06:39-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-02-22T15:06:39-04:00</updated>

		<published>2008-02-22T15:06:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81073#p81073</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81073#p81073"/>
		<title type="html"><![CDATA[list and join problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81073#p81073"><![CDATA[
Looking at the script I see multiple issues, including incompatible types, non-tcl syntax (half of the script looks like php), and other issues...<br><ul><li><div class="codebox"><p>Code: </p><pre><code>set iwas(topic) [lrange $arg 0 100]</code></pre></div><em class="text-italics">$arg</em> is a string, not a list. If you are trying to grab the 100 first characters in the string, use <em class="text-italics">string range</em>.</li><li><div class="codebox"><p>Code: </p><pre><code>set newlist [list $iwas(topic)]</code></pre></div>This would create a list with one single list-item, I'm quite sure this is not what you intended. If you wish to convert a string into a list, use the <em class="text-italics">split</em> command with suitable splitcharacters (works in a similar fashion to explode() in php).</li><li><div class="codebox"><p>Code: </p><pre><code> if ([string first "--lt" [string tolower $arg]] != -1) {</code></pre></div>This would be php-syntax, not tcl-syntax. Very simplified, <em class="text-italics">if</em> expects the "test" to be a string containing one or more tcl-expressions. This string will then be passed to the tcl-interpreter and the result-code is then tested. As a rule of thumb, you (almost) always want to enclose the string with {} (to prevent early evaluation).</li><li><div class="codebox"><p>Code: </p><pre><code>set newlist [[lreplace $newlist $npl $npls $flink]]</code></pre></div>This is very dangerous code, as it will try to execute the result from the lreplace-operation as a separate command, and set newlist to the result of this. In the tcl-preprocessor, <em class="text-italics">[string]</em> means execute <em class="text-italics">string</em> in the current interpreter, and replace <em class="text-italics">[string]</em> with whatever it returns, before the whole commandline is then passed to the current interpreter.</li><li><blockquote class="uncited"><div>[12:18] can't read "chan": no such variable<br>while executing<br>"putserv "TOPIC $chan :$newlist""<br>(file "scripts/iwa.tcl" line 179)<br>invoked from within<br>"source scripts/iwa.tcl"</div></blockquote>This error would suggest that the line <em class="text-italics">putserv "TOPIC $chan :$newlist"</em> was executed as the script was loaded, and not as part of the proc. That is, it would seem there are some unbalanced {} within your script, one of those being this part:<div class="codebox"><p>Code: </p><pre><code>      #if requested the site url      if([string first "--url" [string tolower $arg]] != -1)                  set npl [lsearch $newlist "--url"]         set newlist [[lreplace $newlist $npl $npls $sitelink]]      }</code></pre></div>Here, there is no leading { to start the conditional code block, yet there is one } to terminate it -- which in this case terminates the whole proc instead.</li></ul>I think this covers most of the issues in the posted code...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Feb 22, 2008 3:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[metroid]]></name></author>
		<updated>2008-02-22T09:14:42-04:00</updated>

		<published>2008-02-22T09:14:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81060#p81060</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81060#p81060"/>
		<title type="html"><![CDATA[list and join problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81060#p81060"><![CDATA[
That's not the full code and it looks like you not using lrange on a valid list.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5078">metroid</a> — Fri Feb 22, 2008 9:14 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Mukke]]></name></author>
		<updated>2008-02-22T07:19:30-04:00</updated>

		<published>2008-02-22T07:19:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81059#p81059</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81059#p81059"/>
		<title type="html"><![CDATA[list and join problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81059#p81059"><![CDATA[
when i tried to debug (commented out stuff) i get this:<br><br><div class="codebox"><p>Code: </p><pre><code>proc iwa:topic {nick uhost handle chan arg} {global iwas db mqset flink ""set iwas(topic) [lrange $arg 0 100]set sitelink "\0030,3 http://www.iwaddicts.net/\003"set newlist [lrange $arg 0 100]# check if we have db conectionif {[iwa:constructor $nick $uhost $handle $chan]} {        set qry "SELECT * FROM  phpbb3_posts AS pLEFT JOIN phpbb3_users AS u ON p.poster_id=u.user_idORDER BY  post_time DESC LIMIT 1"set row [lindex [mysqlsel $db(sqlhand) $qry -list] 0]set toad [lindex $row 6]set tijd [ctime $toad]set user [lindex $row 33]set flink "Latest discussion http://board.iwaddicts.net/[lindex $row 2],[lindex $row 1]#p[lindex $row 0]"}##if requested the latest topic#if([string first "--lt" [string tolower $arg]] != -1){#set npl [lsearch $newlist "--lt"]#set newlist [lreplace $newlist $npl $npls $flink]#}##if requested the site url#if([string first "--url" [string tolower $arg]] != -1)#set npl [lsearch $newlist "--url"]#set newlist [lreplace $newlist $npl $npls $sitelink]#}#make the topic and set it in the channel#set newtopic [join $newlist]putserv "TOPIC $chan :$newlist"putlog "#$handle# changed the topic in $chan to $newtopic"}</code></pre></div>Error:<blockquote class="uncited"><div>[12:18] can't read "chan": no such variable<br>    while executing<br>"putserv "TOPIC $chan :$newlist""<br>    (file "scripts/iwa.tcl" line 179)<br>    invoked from within<br>"source scripts/iwa.tcl"</div></blockquote>[/code]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6910">Mukke</a> — Fri Feb 22, 2008 7:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Mukke]]></name></author>
		<updated>2008-02-22T07:08:35-04:00</updated>

		<published>2008-02-22T07:08:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81058#p81058</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81058#p81058"/>
		<title type="html"><![CDATA[list and join problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81058#p81058"><![CDATA[
i was searching for a replace command but i could only find lreplace somehow, ahwell i tried to work around then with lreplace wich agve me this script:<br><br><div class="codebox"><p>Code: </p><pre><code>proc iwa:topic {nick uhost handle chan arg} {global iwas db mqset flink ""set iwas(topic) [lrange $arg 0 100]set sitelink "\0030,3| http://www.iwaddicts.net/ |\003"set newlist [list $iwas(topic)] # check if we have db conectionif {[iwa:constructor $nick $uhost $handle $chan]} {        set qry "SELECT * FROM  phpbb3_posts AS pLEFT JOIN phpbb3_users AS u ON p.poster_id=u.user_idORDER BY  post_time DESC LIMIT 1"set row [lindex [mysqlsel $db(sqlhand) $qry -list] 0]set toad [lindex $row 6]set tijd [ctime $toad]set user [lindex $row 33]set flink "| Latest discussion http://board.iwaddicts.net/[lindex $row 2],[lindex $row 1]#p[lindex $row 0] |"}#if requested the latest topicif([string first "--lt" [string tolower $arg]] != -1){set npl [lsearch $newlist "--lt"]set newlist [[lreplace $newlist $npl $npls $flink]]}#if requested the site urlif([string first "--url" [string tolower $arg]] != -1)set npl [lsearch $newlist "--url"]set newlist [[lreplace $newlist $npl $npls $sitelink]]}#make the topic and set it in the channelset newtopic [join $newlist]putserv "TOPIC $chan :$newtopic"putlog "#$handle# changed the topic in $chan to $newtopic"}</code></pre></div>error:<br>12:04] can't read "newlist": no such variable<br>    while executing<br>"join $newlist"<br>    invoked from within<br>"set newtopic [join $newlist]"<br>    (file "scripts/iwa.tcl" line 178)<br>    invoked from within<br>"source scripts/iwa.tcl"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6910">Mukke</a> — Fri Feb 22, 2008 7:08 am</p><hr />
]]></content>
	</entry>
	</feed>
