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

	<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>2006-06-11T12:08:41-04:00</updated>

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

		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-06-11T12:08:41-04:00</updated>

		<published>2006-06-11T12:08:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=63899#p63899</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=63899#p63899"/>
		<title type="html"><![CDATA[no-crash script loader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=63899#p63899"><![CDATA[
Just thought I'd post my little script that I created after reading the post by sky. This allows loading any script without it crashing the bot (wish I had found this sooner! &lt;g&gt;)  This is how the script is loaded in eggdrop.conf:<br><br>##### SCRIPTS #####<br>source scripts/scripts.txt<br><br>and then the scripts.txt file uses:<div class="codebox"><p>Code: </p><pre><code>set error ""foreach script {alltools.tclcmd_resolve.tclwhatever-script-one-per-line.tcl} {catch {source scripts/$script} errorif {$error != ""} {putcmdlog "\002SCRIPT ERROR\002:$script\: $::errorInfo"}}</code></pre></div>Never have another bot crash from a script error on load <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=7395">rosc2112</a> — Sun Jun 11, 2006 12:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2005-08-17T01:38:51-04:00</updated>

		<published>2005-08-17T01:38:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=54367#p54367</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=54367#p54367"/>
		<title type="html"><![CDATA[searching for errors/bugs in a script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=54367#p54367"><![CDATA[
small correction: the <a href="http://www.tcl.tk/man/tcl8.5/TclCmd/trace.htm#M14" class="postlink">trace</a> command handler is invoked with 3 arguments, not 1; so [logger] actually becomes:<div class="codebox"><p>Code: </p><pre><code>proc logger {name1 name2 op} {   # stuff}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Wed Aug 17, 2005 1:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[sKy]]></name></author>
		<updated>2005-08-15T06:50:22-04:00</updated>

		<published>2005-08-15T06:50:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=54279#p54279</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=54279#p54279"/>
		<title type="html"><![CDATA[searching for errors/bugs in a script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=54279#p54279"><![CDATA[
If you have big scripts and many procs which will call each other and you don`t know really which proc got called by another one you can use this.<div class="codebox"><p>Code: </p><pre><code># strace (original by Elven http://tclhelp.net/forum/viewtopic.php?t=96)# usage:# putlog [strace]proc strace { {args ""} } { if { [info level] == 1 } {return "strace: got called directly by the interpreter (e.g.: .tcl on the partyline)."}       set ret {}        set r [catch {expr [info level] - 1} l]        if {$r} { return {""} }        while {$l &gt; -1} {                incr l -1                lappend ret [info level $l]        } set ret [lremove $ret [lindex $ret [expr [llength $ret] - 2]]]set last [lrange $ret end end]set ret [lreplace $ret end end]eval lappend last $retset while_protection 0while { [llength $last] != 0 } {set x [lindex $last end]set last [lremove $last $x]if { $x == "" } {break}set x [lindex [split $x] 0]lappend newlist $xincr while_protectionif { $while_protection &gt; 100 } {putlog "strace: breaking loop, to many executions (&gt;100)."break}}set newlist [join [split $newlist] " --&gt; "]return $newlist}</code></pre></div>Examaple for what this proc can be used for:<div class="codebox"><p>Code: </p><pre><code>proc test_a args { test_b 2 2 2 }proc test_b args { test_c 3 3 3 }proc test_c args { test_d 4 4 4 }proc test_d args { test_e 5 5 5 }proc test_e args { putlog "procname: test_e: strace: [strace]" }</code></pre></div>type: .tcl test_e<br><br>This will show you which proc got called first, which second, etc...<br><br>--<br><blockquote class="uncited"><div>Tcl error: invalid command name "s"</div></blockquote>Yeah nice :/ You have many procs and don`t know which script cause this error... How can you find more fast? (<a href="http://www.tcl.tk/man/tcl8.5/TclCmd/unknown.htm" class="postlink">http://www.tcl.tk/man/tcl8.5/TclCmd/unknown.htm</a>)<br><div class="codebox"><p>Code: </p><pre><code>if { [info command unknown_new] == "" } {rename unknown unknown_new}proc unknown { args } {set command [join [lrange [split $args] 0 0]]set arg [join [lrange [split $args] 1 end]]putlog "WARNING: unknown command: $command (arguments: $arg) | Lastbind: $::lastbind"uplevel #1 [list unknown_new $args]}</code></pre></div>Another nice tcl feature is the errorInfo varibale. I wonder that so less people know it.<br><div class="codebox"><p>Code: </p><pre><code>bind dcc n|- e dcc:errorinfoproc dcc:errorinfo { handle idx text } {putlog $::lastbindputlog $::errorInfo}</code></pre></div>This will show a multi line traceback to the last error. If you read this you will know what you have to do to prevent this error.<br>The ugly point is, errorInfo shows always the last error. So, if you use catch and a error has been caused it will show that error last, so be fast <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink">.<br><br>thom\mey showed me a nice way to handle that.<div class="codebox"><p>Code: </p><pre><code>trace add variable ::errorInfo write logerrproc logerr { args } {  if { [set utm [utimerexists errorlog]] != "" } { return }  utimer 1 errorlog}proc errorlog { } {  set fs [open errorlog.txt a]  regsub -all -- {\n|\s+} $::errorInfo { } error  putlog $::errorInfo  puts $fs "\n"  puts $fs "[clock format [clock seconds] -format "%d/%m/%y@%H:%M.%S&gt;"] : $::errorInfo"  close $fs}</code></pre></div>Well, in some case this will create a big error errorlog.txt. I don`t know... Do you want this? But the putlog works nice for me.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6101">sKy</a> — Mon Aug 15, 2005 6:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[sKy]]></name></author>
		<updated>2005-08-15T07:01:56-04:00</updated>

		<published>2005-08-15T06:39:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=54278#p54278</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=54278#p54278"/>
		<title type="html"><![CDATA[searching for errors/bugs in a script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=54278#p54278"><![CDATA[
Here are some tips which should help you to find errors or bugs in a script.<br>Firstly i suggest to read this thread: <a href="http://forum.egghelp.org/viewtopic.php?t=10215" class="postlink">http://forum.egghelp.org/viewtopic.php?t=10215</a><br><br>Questions like "How the bot won`t do this or this" won`t really help you or others to find out why. The better way may be to try to understand how tcl works.<br><br>The following short proc will putlog the procname and the variables of the atual proc.<blockquote class="uncited"><div>name-of-proc args1 ?arg arg ...?</div></blockquote><div class="codebox"><p>Code: </p><pre><code>proc logCaller {} { set r [catch {info level [expr [info level] - 1]} e] if {$r} {  putlog "Called directly by the interpreter (e.g.: .tcl on the partyline)." } { putlog "Called by ${e}." } }</code></pre></div>or you can use: putlog "procname $var $var2 ..."<br>Always, if something won`t work and you have no idea why then you should use putlog to show you the exact point of the problem and the content of your variables, returncodes etc.<br><br>--<br>Beware of adding scripts to your config and to type .rehash without testing them. If there are unbalanced barces this will crash your bot which means you have to restart him. To load a script on the save way you have to use the source command in combination with catch. Something like that should be useful:<div class="codebox"><p>Code: </p><pre><code># .s scriptname# not .s scriptname.tclbind dcc n|- s script:loadproc script:load { handle idx text } {if { [catch { uplevel #0 [list source scripts/$text.tcl] } error] } {putlog "0,4Error while loading $text -- Errormsg: $error"putlog "script: $text -- ::errorInfo: $::errorInfo"return} putlog "script: $text -- loaded without error."return}</code></pre></div>That`s how i suggest you should scripts if you are not 100% sure if there is no error inside.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6101">sKy</a> — Mon Aug 15, 2005 6:39 am</p><hr />
]]></content>
	</entry>
	</feed>
