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

	<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-04-09T12:42:12-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-09T12:42:12-04:00</updated>

		<published>2003-04-09T12:42:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18793#p18793</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18793#p18793"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18793#p18793"><![CDATA[
hehe ok  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"> <br>I agree with u  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_cool.gif" width="15" height="15" alt="8)" title="Cool"><p>Statistics: Posted by Guest — Wed Apr 09, 2003 12:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-04-09T11:56:21-04:00</updated>

		<published>2003-04-09T11:56:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18790#p18790</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18790#p18790"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18790#p18790"><![CDATA[
OOPs, no, not directed at you.<br><br>Though the first sentance did apply. It aint allways easy to learn a new language, when you are used to antoher.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Wed Apr 09, 2003 11:56 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-09T11:22:44-04:00</updated>

		<published>2003-04-09T11:22:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18788#p18788</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18788#p18788"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18788#p18788"><![CDATA[
<blockquote class="uncited"><div>There are many however, that tend to thing "It doens't work the way X language works, it is crap". <br><br>The worst people are the ones that put another laguage down, for not doing what they want, when it is often them forgetting that method are not the same.</div></blockquote>Is this referring to me?  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused"><br>I only said im used to java <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><p>Statistics: Posted by Guest — Wed Apr 09, 2003 11:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-04-09T11:10:55-04:00</updated>

		<published>2003-04-09T11:10:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18787#p18787</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18787#p18787"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18787#p18787"><![CDATA[
There are many people various programming backgrounds. Switch to and from a new language isn't allways easy.<br><br>There are many however, that tend to thing "It doens't work the way X language works, it is crap".<br><br>The worst people are the ones that put another laguage down, for not doing what they want, when it is often them forgetting that method are not the same.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Wed Apr 09, 2003 11:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-09T10:46:10-04:00</updated>

		<published>2003-04-09T10:46:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18783#p18783</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18783#p18783"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18783#p18783"><![CDATA[
ok thanks again <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>/me is Java programmer .. works abit different there  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><p>Statistics: Posted by Guest — Wed Apr 09, 2003 10:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-04-09T10:32:22-04:00</updated>

		<published>2003-04-09T10:32:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18782#p18782</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18782#p18782"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18782#p18782"><![CDATA[
The return value is detmined by the last command to take place.<br><br>Each and every command returns a value. In many cases, thsi value is invisible to normal Tcl. Take the following examples, and I will show you what they return.<br><div class="codebox"><p>Code: </p><pre><code>proc hand {} {  return 1}proc test1 {} {  set a [hand]  return $a}proc test2 {} {  return [hand]}proc test3 {} {  hand}</code></pre></div>Test1, 2 &amp; 3 all return 1<br><br>Test1 is obvious to how it works, and test2 is a simplified version.<br><br>In test3, the command "hand" is called. The return value (no the return code) is set to 1. Once it comes back down into test3, the return value buffer is not cleared (the return value buffer is cleared at the start of calling a command). Because there is still a value in the buffer, it is also returned by test3.<br><br>The "set" command, returns that value of the variable passed, or the value it has just been set to. In other words, the reason what your catch stament is called.<br><br>In your first catch block, you have the "close" command. This doesn't return any value at all. As noted above, the buffer is cleared at the start of a command, and because it isn't filled again by the close command, there is nothing in the rturn value.<br><br>The way to your script working, is not to test the value of the err_msg variable. It is to test the value returned from the catch command. It returns 1 on error, 0 on all ok (TCL_OK).<br><br>EG<div class="codebox"><p>Code: </p><pre><code>proc create_file_from_list {filename data_list} {   if {[catch {     set fc [open $filename w]     puts -nonewline $fc $data_list     close $fc   } err_msg]} {    return [list -1 "Error while writing file"]   } else {     return [list 0]   } }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Wed Apr 09, 2003 10:32 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-09T10:22:20-04:00</updated>

		<published>2003-04-09T10:22:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18781#p18781</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18781#p18781"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18781#p18781"><![CDATA[
Ok now it's clear to me  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_cool.gif" width="15" height="15" alt="8)" title="Cool"> <br>Thanks for your time.<p>Statistics: Posted by Guest — Wed Apr 09, 2003 10:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2003-04-09T10:23:28-04:00</updated>

		<published>2003-04-09T10:14:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18777#p18777</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18777#p18777"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18777#p18777"><![CDATA[
<blockquote class="uncited"><div>My point is : How is the return-value from 'script' determined?</div></blockquote>It returns the value of the last executed command before leaving the proc.<br><br>Example:<br><div class="codebox"><p>Code: </p><pre><code>catch {    set value 1    set value 2} err_msg puts "The Error Message:"puts $err_msg</code></pre></div>Assuming your script has no errors, the last successfully executed command is the [close $fc].<br><br><a href="http://www.tcl.tk/man/tcl8.4/TclCmd/close.htm" class="postlink">http://www.tcl.tk/man/tcl8.4/TclCmd/close.htm</a> says:<br><blockquote class="uncited"><div><br>The command returns an empty string, and may generate an error if an error occurs while flushing output.<br></div></blockquote>What you should test for, is the value the [catch] command returns, not the err_msg.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Wed Apr 09, 2003 10:14 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-09T09:56:29-04:00</updated>

		<published>2003-04-09T09:56:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18774#p18774</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18774#p18774"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18774#p18774"><![CDATA[
Yes , I read that.<br>But why doesnt err_msg get set in the first code-sample? Cause this code also contains a 'set' line? <br><div class="codebox"><p>Code: </p><pre><code>set fc [open $filename w]</code></pre></div>Does err_msg only get set to the return value when there's only one command between the catch-braces ? (Or when its the last line maybe?)<br><br>My point is : How is the return-value from 'script' determined?<p>Statistics: Posted by Guest — Wed Apr 09, 2003 9:56 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2003-04-09T09:41:45-04:00</updated>

		<published>2003-04-09T09:41:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18773#p18773</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18773#p18773"/>
		<title type="html"><![CDATA[Re: problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18773#p18773"><![CDATA[
<blockquote class="uncited"><div>Now the following code seems to set the error_msg var ALWAYS, even when the datetime_string is in the correct format.<br><br>Can someone tell me why?<br>Thanks.</div></blockquote><a href="http://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm" class="postlink">http://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm</a> says:<br><blockquote class="uncited"><div><br>If script does not raise an error, catch will return 0 (TCL_OK) and set the variable to the value returned from script.<br></div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Wed Apr 09, 2003 9:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-04-09T09:14:10-04:00</updated>

		<published>2003-04-09T09:14:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18772#p18772</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18772#p18772"/>
		<title type="html"><![CDATA[problem with the catch command]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18772#p18772"><![CDATA[
Hi ppl,<br><br>Hope someone can help me out with this.<br><br>This code returns a list containing an errormsg when there occured a problem while writing the file, no errormsg if the writing was succesful:<br><div class="codebox"><p>Code: </p><pre><code>proc create_file_from_list {filename data_list} {   catch {    set fc [open $filename w]    puts -nonewline $fc $data_list    close $fc  } err_msg  if {$err_msg!=""} {    return [list -1 "Error while writing file"]  } else {    return [list 0]  }}</code></pre></div>Now the following code seems to set the error_msg var ALWAYS, even when the datetime_string is in the correct format.<br><div class="codebox"><p>Code: </p><pre><code>catch {    set timestamp [clock scan $datetime_string]  } err_msg  if {$err_msg!=""} {    return [list -1 "Invalid format for 'date'. Correct format: $timestamp_format"]  } else {    return [list 0 $timestamp]  }</code></pre></div>Can someone tell me why?<br>Thanks.<p>Statistics: Posted by Guest — Wed Apr 09, 2003 9:14 am</p><hr />
]]></content>
	</entry>
	</feed>
