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

	<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-02-23T01:35:51-04:00</updated>

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

		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2006-02-23T01:35:51-04:00</updated>

		<published>2006-02-23T01:35:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=60596#p60596</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=60596#p60596"/>
		<title type="html"><![CDATA[Reading and writing to files]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=60596#p60596"><![CDATA[
you just downloaded eggdrop and you are already trying to write nontrivial seen script? wow<br><br>I think you are totally confused about the basic principles of saving data from eggdrop scripts; you should load data on script's startup, do all of your data handling in memory and only periodically write to file<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Thu Feb 23, 2006 1:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2006-02-22T17:35:48-04:00</updated>

		<published>2006-02-22T17:35:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=60586#p60586</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=60586#p60586"/>
		<title type="html"><![CDATA[Reading and writing to files]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=60586#p60586"><![CDATA[
Maybe <a href="http://forum.egghelp.org/viewtopic.php?t=5698" class="postlink">this</a> might help. See code by user.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Wed Feb 22, 2006 5:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Christmas]]></name></author>
		<updated>2006-02-22T10:12:04-04:00</updated>

		<published>2006-02-22T10:12:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=60578#p60578</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=60578#p60578"/>
		<title type="html"><![CDATA[Reading and writing to files]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=60578#p60578"><![CDATA[
Well I created a list, each element of it contains a line of the file and if $nick exists in the list, that element gets replaced with the new info for $host, $date and $time, or else the $nick, $host, $date and $time are appended to the list as a new element at the end. Well if I write this list to a file (element by element) it take the same time as before...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7386">Christmas</a> — Wed Feb 22, 2006 10:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2006-02-22T07:22:10-04:00</updated>

		<published>2006-02-22T07:22:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=60576#p60576</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=60576#p60576"/>
		<title type="html"><![CDATA[Reading and writing to files]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=60576#p60576"><![CDATA[
You can read the file into a list, remove the line you want using [lreplace] and then save back.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Wed Feb 22, 2006 7:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Christmas]]></name></author>
		<updated>2006-02-22T05:39:25-04:00</updated>

		<published>2006-02-22T05:39:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=60575#p60575</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=60575#p60575"/>
		<title type="html"><![CDATA[Reading and writing to files]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=60575#p60575"><![CDATA[
Hy all! This is my first post here, I just downloaded eggdrop and I'm a newbie to TCL scripting. I scripted in mIRC scripting before but TCL brings new and harder topics to understand. Well what I need (and could not find out) is how can I overwrite a line in a file without the need of reading the previous lines or using a temporary file. Here is my code that I have now: <div class="codebox"><p>Code: </p><pre><code>bind part - * data_seenproc data_seen {nick uhost hand chan text} {set file1 [open "DSotM/Temp/Seen.txt" r]set file2 [open "DSotM/Temp/Tmp/Seen.txt" w]set host [lindex [split $uhost @] 1]set date [clock format [clock seconds] -format "%D"]set time [clock format [clock seconds] -format "%T"]set contor 0while {[gets $file1 line] &gt;= 0 &amp;&amp; $contor == 0} {if {[lindex $line 0] == $nick} {puts $file2 "$line"}}puts $file2 "$nick $host $date $time"close $file1close $file2file copy -force "DSotM/Temp/Tmp/Seen.txt" "DSotM/Temp/Seen.txt"file delete "DSotM/Temp/Tmp/Seen.txt"}</code></pre></div>Now this script is opening the original file, $file1, read lines from it and if the nick that parted the channel it's not the nick in the file, it writes that line to a temporary file. Then at the end it appends the nick, host, date and time variables to that temp file and then it overwrites the original file. Now this works for small files, but with files larger than 1000 nicks (and that is very possible for a crowded channel) this proccess of reading and writing takes veeeeery much time. How can insert that $nick $host $date $time at a defined line in the original file, so I won't have 2 lines with the same nick on them?<br><br>Thank you in advance, Christmas_.<br><br>LE: Sorry for that code formatting, how do I use that code tags? <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=7386">Christmas</a> — Wed Feb 22, 2006 5:39 am</p><hr />
]]></content>
	</entry>
	</feed>
