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

	<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-05-14T03:59:48-04:00</updated>

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

		<entry>
		<author><name><![CDATA[SCR34M3R]]></name></author>
		<updated>2009-05-14T03:59:48-04:00</updated>

		<published>2009-05-14T03:59:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88759#p88759</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88759#p88759"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88759#p88759"><![CDATA[
awesome, Works a treat.<br>Thanks heaps guys<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10650">SCR34M3R</a> — Thu May 14, 2009 3:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-05-13T09:40:05-04:00</updated>

		<published>2009-05-13T09:40:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88748#p88748</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88748#p88748"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88748#p88748"><![CDATA[
Thnx for pointing it out, I'll update my post in a sec or two.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed May 13, 2009 9:40 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Papillon]]></name></author>
		<updated>2009-05-13T09:31:06-04:00</updated>

		<published>2009-05-13T09:31:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88747#p88747</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88747#p88747"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88747#p88747"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>set fd [open thefile "RDONLY"]set tmp [split [read -nonewline $thefile] "\n"] </code></pre></div>should be $fd, as in:<div class="codebox"><p>Code: </p><pre><code>set fd [open thefile "RDONLY"]set tmp [split [read -nonewline $fd] "\n"] </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=852">Papillon</a> — Wed May 13, 2009 9:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-05-13T09:41:46-04:00</updated>

		<published>2009-05-13T08:42:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88746#p88746</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88746#p88746"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88746#p88746"><![CDATA[
Easiest modification here then, would probably to use list operations..<br><br>The approach, roughly put, is to open the file as read-only, and read the whole content. Then use <strong class="text-strong">split</strong> to convert the raw data into a list.<br>Once we've got a list, we can use commands such as <strong class="text-strong">lappend</strong>/<strong class="text-strong">linsert</strong> and <strong class="text-strong">lrange</strong> to manipulate the list to suit our needs.<br>When we're satisfied with our new list, we then use <strong class="text-strong">join</strong> to restore it to "raw data", and write it back to our file (which now has been opened as write-only).<br><br>A rough example:<div class="codebox"><p>Code: </p><pre><code>set fd [open thefile "RDONLY"]set tmp [split [read -nonewline $fd] "\n"]# Read the data, and split it on newlines...close $fdset fd [open thefile "WRONLY CREAT TRUNC"]# Re-open the file in write-only mode, creating the file if it's missing, and clearing any previous content.puts $fd [join [lrange [linsert $tmp 0 $data] 0 9] "\n"]# Insert $data at the beginning of the list, then trim the list to the first 10 items, and finally join it back into a textstring, separating each list item with a newline. Write it back into (the empty) file.close $fd</code></pre></div>I've stacked a few steps of the process here, hope you get the picture anyway.<br><br>Edit: fixed minor bummer... Thank you papillon for pointing it out.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed May 13, 2009 8:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SCR34M3R]]></name></author>
		<updated>2009-05-13T07:04:34-04:00</updated>

		<published>2009-05-13T07:04:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88745#p88745</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88745#p88745"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88745#p88745"><![CDATA[
its the sitelist.tcl which i have edited a bit to suit what i need.<br>the add section is <div class="codebox"><p>Code: </p><pre><code>## Operation Proceduresproc prc_addsite {site} {global sitefile        if {[catch {open $sitefile a} fd]} {                return 0        } else {                puts $fd $site                close $fd                return 1        }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10650">SCR34M3R</a> — Wed May 13, 2009 7:04 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-05-12T10:07:09-04:00</updated>

		<published>2009-05-12T10:07:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88737#p88737</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88737#p88737"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88737#p88737"><![CDATA[
That kind of depends on what you've done so far, and how you've approached adding/deleting lines.<br><br>If you're using read-&gt;split approach, it'd be pretty much a matter of adding the new list item and then using lrange to restrict the set to 10 items (lines).<br>Other approaches would require other techniques..<br><br>Post what you've got so far, and we'll go from there..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue May 12, 2009 10:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SCR34M3R]]></name></author>
		<updated>2009-05-12T03:51:00-04:00</updated>

		<published>2009-05-12T03:51:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88736#p88736</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88736#p88736"/>
		<title type="html"><![CDATA[Max 10 lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88736#p88736"><![CDATA[
hay guys <br>pretty new to tcl scripting, But got myself a add,del and list script going, but i want it so when i do !add text, it checks the file and deletes the oldest entry into the file. So that there is only 10 lines in the file.<br><br>So Add entry to Top, Remove last line.<br><br>How would i go about doing this?<br><br>Cheers in Advanced<br>Justin<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10650">SCR34M3R</a> — Tue May 12, 2009 3:51 am</p><hr />
]]></content>
	</entry>
	</feed>
