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

	<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>2009-09-19T06:54:17-04:00</updated>

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

		<entry>
		<author><name><![CDATA[HÒóme]]></name></author>
		<updated>2009-09-19T06:54:17-04:00</updated>

		<published>2009-09-19T06:54:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90288#p90288</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90288#p90288"/>
		<title type="html"><![CDATA[change a line in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90288#p90288"><![CDATA[
It works fine.<br><br><br>Thank you very much<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10853">HÒóme</a> — Sat Sep 19, 2009 6:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2009-09-19T05:52:07-04:00</updated>

		<published>2009-09-19T05:52:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90287#p90287</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90287#p90287"/>
		<title type="html"><![CDATA[change a line in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90287#p90287"><![CDATA[
Since you have a specific line you wish to replace (3), then as demonstrated by arfer you can use [lreplace] to replace it.<div class="codebox"><p>Code: </p><pre><code># read data from fileset data [split [read [set id [open $file]]][close $id] \n]# replace 4th line (index 3)set data [lreplace $data 3 3 $changelineto]# rewrite the file with changed dataputs [set id [open $file w]] [join $data \n]close $id</code></pre></div>Note that index 3 in Tcl means the 4th line (starting from 0).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sat Sep 19, 2009 5:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[HÒóme]]></name></author>
		<updated>2009-09-19T02:09:16-04:00</updated>

		<published>2009-09-19T02:09:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90286#p90286</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90286#p90286"/>
		<title type="html"><![CDATA[change a line in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90286#p90286"><![CDATA[
I cant run it.... Or has any error in code, or i am doing some thing wrong...<br><br>Well... i wanted something like this:<br><div class="codebox"><p>Code: </p><pre><code>bind pub - !line changelineproc changeline { nick uhost hand chan text } {set line "3"set file "scripts/script.tcl"set changelineto "$text"[[ Code to change the line ]]putserv "privmsg $chan :Changed"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10853">HÒóme</a> — Sat Sep 19, 2009 2:09 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-09-18T15:01:15-04:00</updated>

		<published>2009-09-18T15:01:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90282#p90282</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90282#p90282"/>
		<title type="html"><![CDATA[change a line in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90282#p90282"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>set oldline "This is how the line reads before replacement"set newline "This is how the line should read after replacement"set id [open filename.txt r]set data [split [read -nonewline $id] \n]close $idfor {set loop 0} {$loop &lt; [llength $data]} {incr loop} {    if {[string equal $oldline [lindex $data $loop]]} {        lreplace $data $loop $loop $newline    }}set id [open filename.txt w]puts -nonewline $id [join $data \n]close $id</code></pre></div>There are obviously variations on this theme. You might only know part of the line and need to use 'string match' or 'string match -nocase' or even a 'regexp' to determine if it is the line to be replaced.<br><br>You may also only require the first incidence of a line to be changed, in which case you would have to break out of the 'for' loop after finding it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Fri Sep 18, 2009 3:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[TCL_no_TK]]></name></author>
		<updated>2009-09-18T14:57:03-04:00</updated>

		<published>2009-09-18T14:57:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90281#p90281</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90281#p90281"/>
		<title type="html"><![CDATA[change a line in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90281#p90281"><![CDATA[
There is loads ov posts about this on the forum, try search'ing for them, best bet would be this post thou <a href="http://forum.egghelp.org/viewtopic.php?t=6885" class="postlink">http://forum.egghelp.org/viewtopic.php?t=6885</a> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_idea.gif" width="15" height="15" alt=":idea:" title="Idea"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8130">TCL_no_TK</a> — Fri Sep 18, 2009 2:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[HÒóme]]></name></author>
		<updated>2009-09-18T13:37:37-04:00</updated>

		<published>2009-09-18T13:37:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90280#p90280</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90280#p90280"/>
		<title type="html"><![CDATA[change a line in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90280#p90280"><![CDATA[
Hi.<br><br>How can i change a line in a file using eggdrop?<br><br>Thanks in advance<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10853">HÒóme</a> — Fri Sep 18, 2009 1:37 pm</p><hr />
]]></content>
	</entry>
	</feed>
