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

	<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>2005-08-09T03:34:54-04:00</updated>

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

		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2005-08-09T03:34:54-04:00</updated>

		<published>2005-08-09T03:34:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53925#p53925</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53925#p53925"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53925#p53925"><![CDATA[
{} is the last (empty) string which you get when splitting data by \n and your file ends with \n<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Tue Aug 09, 2005 3:34 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darkmare]]></name></author>
		<updated>2005-08-08T22:26:42-04:00</updated>

		<published>2005-08-08T22:26:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53907#p53907</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53907#p53907"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53907#p53907"><![CDATA[
OK, there's two places that could go, though I'm pretty sure you meant the one in the while statement.  More importantly to me is *why* is that getting in there? I mean, where is that token coming from?  Is this some default behaviour I could override?<br><br>OK, I found it.  Easier solution is to change the &lt;= to &lt; <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=4813">darkmare</a> — Mon Aug 08, 2005 10:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2005-08-08T21:38:30-04:00</updated>

		<published>2005-08-08T21:38:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53905#p53905</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53905#p53905"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53905#p53905"><![CDATA[
Try [split $arg] instead of $arg.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Mon Aug 08, 2005 9:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darkmare]]></name></author>
		<updated>2005-08-08T20:09:20-04:00</updated>

		<published>2005-08-08T20:09:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53902#p53902</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53902#p53902"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53902#p53902"><![CDATA[
OK, we're getting somewhere now.  The code that works is as follows: (Mostly so those that come after me see what the fix was)<div class="codebox"><p>Code: </p><pre><code>proc act:trigger {nick mask hand chan keyword arg} {if {[lindex $arg 0] == "Pix"} {global temp_file data counter temp_string file_name lengthset temp_file ""set data ""set temp_string ""set file_name [lindex $arg 3]if {[lindex $arg 2] == "create"} {set temp_file [open $file_name "w+"]putserv "PRIVMSG $chan :\001ACTION created file named $file_name\001"close $temp_fileputserv "PRIVMSG $chan :\001ACTION closed file named $file_name\001"return}if {[lindex $arg 2] == "read"} {set temp_file [open $file_name "r"]putserv "PRIVMSG $chan :\001ACTION opened file named $file_name\001"putserv "PRIVMSG $chan :\001ACTION read file named $file_name\001"set data [read -nonewline $temp_file]set temp_string [split $data "\n"]set length [llength $temp_string]putserv "PRIVMSG $chan :\001ACTION is parsing data. . .\001"set counter 0while {$counter &lt; $length} {putserv "PRIVMSG $chan :\001ACTION sees \"[lindex $temp_string $counter]\" as line $counter in $file_name.\001"incr counter}close $temp_fileputserv "PRIVMSG $chan :\001ACTION closed file named $file_name\001"return}if {[lindex $arg 2] == "append"} {putserv "PRIVMSG $chan :\001ACTION opened file named $file_name\001"set temp_string ""set counter 4while {$counter &lt;= [llength $arg]} {lappend temp_string [lindex $arg $counter]incr counter}set temp_file [open $file_name "a"]puts $temp_file $temp_stringputserv "PRIVMSG $chan :\001ACTION appended \"$temp_string\" to file named $file_name\001"close $temp_fileputserv "PRIVMSG $chan :\001ACTION closed file named $file_name\001"return}}}</code></pre></div>Now, while not an error per se, I am getting some strange stuff:<blockquote class="uncited"><div>* AuntieChrist Pix file append test.egt I Like Blue.<br>* PixelCatv2 opened file named test.egt<br>* PixelCatv2 appended "I Like Blue. {}" to file named test.egt<br>* PixelCatv2 closed file named test.egt<br>* AuntieChrist Pix file read test.egt<br>* PixelCatv2 opened file named test.egt<br>* PixelCatv2 read file named test.egt<br>* PixelCatv2 is parsing data. . .<br>* PixelCatv2 sees "Now for something *really* different. {}" as line 0 in test.egt.<br>* PixelCatv2 sees "Something not so different. {}" as line 1 in test.egt.<br>* PixelCatv2 sees "I Like Blue. {}" as line 2 in test.egt.<br>* PixelCatv2 closed file named test.egt</div></blockquote>Where are those braces and the space coming from?  Is there a way to get rid of them?<br><br>And thanks for the help<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4813">darkmare</a> — Mon Aug 08, 2005 8:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darkmare]]></name></author>
		<updated>2005-08-08T19:04:56-04:00</updated>

		<published>2005-08-08T19:04:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53901#p53901</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53901#p53901"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53901#p53901"><![CDATA[
I meant, I read all the FAQs and such; I didn't look at dates for any new ones, *that* part is my bad  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4813">darkmare</a> — Mon Aug 08, 2005 7:04 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2005-08-08T19:01:42-04:00</updated>

		<published>2005-08-08T19:01:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53900#p53900</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53900#p53900"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53900#p53900"><![CDATA[
<blockquote class="uncited"><div>Well, I did, but it was over a year ago <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>Hehe, demond's post is less than a week old <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><br><br>Anyway, the first thing I caught was this:<div class="codebox"><p>Code: </p><pre><code>set data [read -nonewline $temp_file]</code></pre></div>you already closed $temp_file, you can't read it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Mon Aug 08, 2005 7:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darkmare]]></name></author>
		<updated>2005-08-08T18:57:21-04:00</updated>

		<published>2005-08-08T18:57:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53899#p53899</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53899#p53899"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53899#p53899"><![CDATA[
Well, I did, but it was over a year ago <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile">  I only come here when I've gone over stuff for hours, and no luck, hence the long time between visits.  My apologies.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4813">darkmare</a> — Mon Aug 08, 2005 6:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2005-08-08T18:51:59-04:00</updated>

		<published>2005-08-08T18:51:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53898#p53898</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53898#p53898"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53898#p53898"><![CDATA[
You didn't read the first sticky topic in this forum, use <div class="codebox"><p>Code: </p><pre><code> tags when showing snippets.</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Mon Aug 08, 2005 6:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darkmare]]></name></author>
		<updated>2005-08-08T18:56:14-04:00</updated>

		<published>2005-08-08T18:37:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=53895#p53895</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=53895#p53895"/>
		<title type="html"><![CDATA[File Reading (Code to learn file functions); error]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=53895#p53895"><![CDATA[
To learn about playing with files, I put this code in the v2-alpha of my bot. (If you'd like to see examples of some of it's new code, go to <a href="http://3whack.org/forums" class="postlink">http://3whack.org/forums</a> and look all the way at the bottom under PIxelCat Dev Team).<br><br>When I try to read the file, it gets all the way through the code, but doesn't spit anything out.  Via the telnet, I get this error: "[15:18] Tcl error [act:trigger]: can not find channel named "file14""<br><br>What shows in channel is this:<br>* AuntieChrist Pix file read test.egt (yeah, I'm silly, I made a file extention for EGgdrop Text)<br>* PixelCatv2 file14<br>* PixelCatv2 opened file named test.egt<br>* PixelCatv2 read file named test.egt<br>* PixelCatv2 closed file named test.egt<br><br>For my tutorial, I used this post here: <a href="http://forum.egghelp.org/viewtopic.php?t=6885" class="postlink">http://forum.egghelp.org/viewtopic.php?t=6885</a><br>The append and create work just fine, the reading isn't.<div class="codebox"><p>Code: </p><pre><code>proc act:trigger {nick mask hand chan keyword arg} {if {[lindex $arg 0] == "Pix"} {global temp_file data counter temp_string file_nameset temp_file ""set data ""set temp_string ""set file_name [lindex $arg 3]if {[lindex $arg 2] == "create"} {set temp_file [open $file_name "w+"]putserv "PRIVMSG $chan :\001ACTION created file named $file_name\001"close $temp_fileputserv "PRIVMSG $chan :\001ACTION closed file named $file_name\001"return}if {[lindex $arg 2] == "read"} {set temp_file [open $file_name "r"]putserv "PRIVMSG $chan :\001ACTION $temp_file\001"putserv "PRIVMSG $chan :\001ACTION opened file named $file_name\001"putserv "PRIVMSG $chan :\001ACTION read file named $file_name\001"close $temp_fileputserv "PRIVMSG $chan :\001ACTION closed file named $file_name\001"set data [read -nonewline $temp_file]putlog "Debug B"set temp_string [split $data "\n"]putserv "PRIVMSG $chan :\001ACTION is parsing data. . .\001"set counter 0while {$counter &lt;= [llength $data]} {putserv "PRIVMSG #chan :\001ACTION sees [lindex $temp_string $counter] as line [$counter + 1] in $file_name.\001"incr counter}return}if {[lindex $arg 2] == "append"} {set temp_file [open $file_name "r"]putserv "PRIVMSG $chan :\001ACTION opened file named $file_name\001"set temp_string ""set counter 4while {$counter &lt;= [llength $arg]} {lappend temp_string [lindex $arg $counter]incr counter}set [lindex $arg 3] [open $file_name "a"]puts $temp_file $temp_stringputserv "PRIVMSG $chan :\001ACTION appended $temp_string to file named $file_name\001"close $temp_fileputserv "PRIVMSG $chan :\001ACTION closed file named $file_name\001"return}}}</code></pre></div>Any help would be appreciated,<br>Brendan<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4813">darkmare</a> — Mon Aug 08, 2005 6:37 pm</p><hr />
]]></content>
	</entry>
	</feed>
