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

	<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>2012-06-28T02:19:23-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-11-16T10:20:02-04:00</updated>

		<published>2008-11-16T10:20:02-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85844#p85844</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85844#p85844"/>
		<title type="html"><![CDATA[Variables]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85844#p85844"><![CDATA[
I do see a few flaws in your script. The first issue at hand is that you don't take variable-spaces into considderation. Variables created in globalspace generally cannot be accessed as local variables within a proc (except unless they've explicitly been linked to a local variable using <strong class="text-strong">upvar</strong> or <strong class="text-strong">global</strong>). Hence, you cannot use <em class="text-italics">$globalvar</em> within your proc to access the globalspace variable <em class="text-italics">globalvar</em>, use <em class="text-italics">$::globalvar</em> instead (or use the <strong class="text-strong">global</strong> command to link it to the localspace variable.<br><br>The second issue is that you named one of your parameters "args" in holm-join_greet raw:qauth. This name has a special meaning, and should be avoided unless you explicitly desire this behaviour ("args", when used as the last parameter in a proc declaration, may accept 0 or more arguments, concatenating them into a tcl-list).<br><br>Third issue is that you keep mixing lists and strings in a way that will cause your script to malfunction under certain conditions. Commands such as lindex expect a list, not a string, and will not operate correctly if the provided data is not a valid tcl-list structure.<br><br>This piece of code pretty much sums up all the above, and I'll add comments explaining the flaws and how to correct them..<div class="codebox"><p>Code: </p><pre><code>bind raw - 311 raw:qauth#Proc has been declared with an "args" parameter, yet the raw binding always calls the proc with a fixed number of arguments.. Hence, args will be a tcl-list with one list-item containing all that the server sent us...proc raw:qauth {from keyword args} { global Qauth Qpass Qhost#Since args is a list, we have to use join to convert it into a string. Using a different parameter name would save us from this extra work... set args [string tolower [join $args]]#But now, we've already converted args into a string, we can't use list operations on it, such as lindex...#Even if we hadn't joined args into a string, you'd still have problems, as the initial list only had one list item containing the whole string, and all you'd end up with is having nick = "" and host = "@".#What you need to do, is convert the string into a list. split usually does the trick here, and it also allows you to specify which character (default space) should be used to "split" upon. set nick [lindex $args 1] set host "[lindex $args 2]@[lindex $args 3]" if {$host == [string tolower $Qhost]} {  puthelp "PRIVMSG Q@CServe.quakenet.org :AUTH $Qauth $Qpass"#Here we try to read the local variable gatherbot, yet it has not been declared anywhere within the proc, thus this will throw an error and abort execution...#Most likely, you were trying to access the globalspace variable with the same name. To do this, you'd either have to use the global command, or use a full path to the variable ($::gatherbot)  puthelp "PRIVMSG $gatherbot :AUTH" }}### The proper code should look something like this instead:bind raw - 311 raw:qauthproc raw:qauth {from keyword text} { global Qauth Qpass Qhost set ltext [split $text] set nick [lindex $ltext 1] set host "[lindex $ltext 2]@[lindex $ltext 3]"#I am using a slightly different way of comparing the hosts, saving me alot of case mangling. if {[string equal -nocase $host $Qhost]} {  puthelp "PRIVMSG Q@CServe.quakenet.org :AUTH $Qauth $Qpass"  puthelp "PRIVMSG $::gatherbot :AUTH" }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Nov 16, 2008 10:20 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[garfwen]]></name></author>
		<updated>2008-11-16T10:06:42-04:00</updated>

		<published>2008-11-16T10:06:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85843#p85843</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85843#p85843"/>
		<title type="html"><![CDATA[Variables]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85843#p85843"><![CDATA[
Yeah ! <br>It's working now.<br><br>Ty<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9777">garfwen</a> — Sun Nov 16, 2008 10:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2008-11-16T09:54:40-04:00</updated>

		<published>2008-11-16T09:54:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85841#p85841</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85841#p85841"/>
		<title type="html"><![CDATA[Variables]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85841#p85841"><![CDATA[
Simple, you create $forum and $site in global space. You may reference them as $forum and $site only when used in global space. If your using them within local space (inside of a procedure) you must add them as global variables in the global line, or reference them as $::forum and $::site.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sun Nov 16, 2008 9:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[garfwen]]></name></author>
		<updated>2008-11-16T09:30:50-04:00</updated>

		<published>2008-11-16T09:30:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85839#p85839</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85839#p85839"/>
		<title type="html"><![CDATA[Variables]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85839#p85839"><![CDATA[
ouh... the help texts are in Portuguese but I dont think its necessary to translate :\<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9777">garfwen</a> — Sun Nov 16, 2008 9:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[garfwen]]></name></author>
		<updated>2012-06-28T02:19:23-04:00</updated>

		<published>2008-11-16T09:25:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85838#p85838</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85838#p85838"/>
		<title type="html"><![CDATA[Variables]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85838#p85838"><![CDATA[
removed<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9777">garfwen</a> — Sun Nov 16, 2008 9:25 am</p><hr />
]]></content>
	</entry>
	</feed>
