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

	<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-03-31T03:56:18-04:00</updated>

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

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-03-31T03:56:18-04:00</updated>

		<published>2003-03-31T03:56:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18377#p18377</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18377#p18377"/>
		<title type="html"><![CDATA[remove]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18377#p18377"><![CDATA[
oh, and here is my code (without your sugestions):<div class="codebox"><p>Code: </p><pre><code>"del" {if {[lindex $text 1] == ""} {putdcc $idx "\002Usage\002: .randtopic &lt;del&gt; &lt;topic&gt;"return 0}set found 0set index ""set info "[lrange [split $text] 1 end]" set file [open $topic(file) r] while {![eof $file]} {set lines [split [read $file] "\n"]foreach line $lines { if {$line == ""} { continue }if {$line == $info} {set found 1} else { lappend index $line }}if {$found == 0} {putdcc $idx "Topic '$info' not found."return }}catch {close $file}set file [open $topic(file) w] foreach line $index {puts $file $line}catch {close $file}putdcc $idx "Topic '$info' removed."}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Mar 31, 2003 3:56 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-03-31T03:53:08-04:00</updated>

		<published>2003-03-31T03:53:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18376#p18376</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18376#p18376"/>
		<title type="html"><![CDATA[remove]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18376#p18376"><![CDATA[
Hi, thanks fotr your reply. I've already figured out what I must do and seems that I've succided. I'll follow your instructions and do one and compare wich one is the best one. <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=187">caesar</a> — Mon Mar 31, 2003 3:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2003-03-31T03:30:58-04:00</updated>

		<published>2003-03-31T03:30:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18375#p18375</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18375#p18375"/>
		<title type="html"><![CDATA[remove]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18375#p18375"><![CDATA[
Your while loop is a bit confused. If you're using [read $file] then that will read in the entire file -- you don't need another loop.<br><br>Then your foreach loop can be easily replaced with lsearch and it will make more sense. Right now you set found to 1, but you don't save the line number. How do you know which line to remove?<br><br>Finally, you have to rewrite the file, just like you said. To do that, open the file in write mode, and puts -nonewline [join $lines \n].<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Mon Mar 31, 2003 3:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-03-31T03:00:32-04:00</updated>

		<published>2003-03-31T03:00:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=18374#p18374</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=18374#p18374"/>
		<title type="html"><![CDATA[remove]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=18374#p18374"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>"del" {if {[lindex $text 1] == ""} {putdcc $idx "\002Usage\002: .randtopic &lt;del&gt; &lt;topic&gt;"return 0}set found 0set info "[lrange [split $text] 1 end]" set file [open $topic(file) r+] while {![eof $file]} {set lines [split [read $file] "\n"]foreach line $lines { if {$line == ""} { continue }if {$line == $info} { set found 1 } }}catch {close $file}if {$found == 1} { putdcc $idx "Topic '$info' removed." } else { putdcc $idx "Topic '$info' not found." }}</code></pre></div>How actualy to do the remove part? I know that I must open the file for reading, read all lines from the file except the line I want to be removed and then close the file and open it again for writing, or open it once and do the reading and writing part. I've did some tests and got stucked..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Mar 31, 2003 3:00 am</p><hr />
]]></content>
	</entry>
	</feed>
