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

	<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>2002-03-05T07:22:00-04:00</updated>

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

		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2002-03-05T07:22:00-04:00</updated>

		<published>2002-03-05T07:22:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=5065#p5065</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=5065#p5065"/>
		<title type="html"><![CDATA[Reading arguments from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=5065#p5065"><![CDATA[
There are several problems with your script.<br><br>First, you shouldn't use [lindex $line 0] unless you're very sure about the file structure, because if it has a special char (eg. {, [), you will have a tcl error.<br><br>Second, you shouldn't test for eof until after you attempt to read from the file. Eof isn't reported until you try to read past the file. So make it something like this:<br>while {[gets $file line] &gt;= 0} {<br>   ...<br>}<br><br>Finally, you can't delete a line from the file by doing puts $file "". What you have to do is read in the entire file, re-open the file in overwrite mode, and then write out everything you don't want deleted.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Tue Mar 05, 2002 7:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2002-03-05T05:06:00-04:00</updated>

		<published>2002-03-05T05:06:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=5060#p5060</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=5060#p5060"/>
		<title type="html"><![CDATA[Reading arguments from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=5060#p5060"><![CDATA[
I'm trying to delete a line from a file with a specified argument. Ie. if the var name would be "[censored]" and it searches for from the file the line and clears it. anyway, this doesn't work. I tried to read from a file a code with this code :<br><br>set filename "test.dat"<br>set file [open $filename]<br>set varname "vartofind"<br><br>while {![eof $file]} {<br> set line [gets $file]<br> if {[lindex $line 0] == $varname]} {<br>  puts $file ""<br> }<br>}<br>close $file<br><br>Hope somebody knows <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":smile:" title="Smile"><p>Statistics: Posted by Guest — Tue Mar 05, 2002 5:06 am</p><hr />
]]></content>
	</entry>
	</feed>
