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

	<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-02-07T03:10:40-04:00</updated>

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

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-07T03:10:40-04:00</updated>

		<published>2003-02-07T03:10:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16277#p16277</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16277#p16277"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16277#p16277"><![CDATA[
Probably I havent seen it in the manual. Thanks for pointing it out..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Fri Feb 07, 2003 3:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-06T17:41:27-04:00</updated>

		<published>2003-02-06T17:41:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16274#p16274</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16274#p16274"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16274#p16274"><![CDATA[
Very true.<br><br>Then the code should now read<br><div class="codebox"><p>Code: </p><pre><code>set file "FILE.NAME"set lines [llength [split [read -nonewline [set fp [open $file r]]] "\n"]]close $fp</code></pre></div>I forget that splitting at the newline, causes a extra blank element.<br><br>Read will leave a newline at the end, because of the nature of files, causing Tcl to think of a new element on split.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Feb 06, 2003 5:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2003-02-06T17:11:00-04:00</updated>

		<published>2003-02-06T17:11:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16271#p16271</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16271#p16271"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16271#p16271"><![CDATA[
<blockquote class="uncited"><div>So it does.<br><br>The w in the open command should be a r.<br><br>However, you said errors, and not error. Can you point any more out?</div></blockquote>Create a one line file and run the script.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Thu Feb 06, 2003 5:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-06T17:07:22-04:00</updated>

		<published>2003-02-06T17:07:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16269#p16269</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16269#p16269"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16269#p16269"><![CDATA[
My advice, is whenever you see a new command introduced, try looking in the Tcl manual, or doing "man &lt;command&gt;" on the shell.<br><blockquote class="uncited"><div>Usage: wc [OPTION]... [FILE]...<br>Print line, word, and byte counts for each FILE, and a total line if<br>more than one FILE is specified.  With no FILE, or when FILE is -,<br>read standard input.</div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Feb 06, 2003 5:07 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-06T16:22:54-04:00</updated>

		<published>2003-02-06T16:22:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16264#p16264</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16264#p16264"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16264#p16264"><![CDATA[
I have said that at that moment I didn't knew another alternative. I havent heard about the "wc" (wordcount) until now. ppslim's advice from changing the w (write) to r (read) seems corectly. There is no need to write, just to read from the file.<br><br>Also I don't see where this "wc" (wordcount) can be used on the *lines* count, not words count..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Feb 06, 2003 4:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-06T15:02:10-04:00</updated>

		<published>2003-02-06T15:02:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16261#p16261</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16261#p16261"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16261#p16261"><![CDATA[
So it does.<br><br>The w in the open command should be a r.<br><br>However, you said errors, and not error. Can you point any more out?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Feb 06, 2003 3:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2003-02-06T11:38:08-04:00</updated>

		<published>2003-02-06T11:38:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16259#p16259</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16259#p16259"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16259#p16259"><![CDATA[
<blockquote class="uncited"><div>Well, not all the things are simple as they look like.. The usage of the 'foreach' thing is logical to be used. I don't have any ideea (at this moment) of another way to do the same thing. Combining mine and ppslim's reply you should solve this in a sec.. Heh..</div></blockquote>Another way is to use OS utilities like "wc" (wordcount). A while loop with an increasing counter usually is not that efficient in terms of CPU usage although memory needs are low.<br><br>For smaller files the script given by ppslim (which contains some errors, finding and solving them are left as a trivial exercise) works ok. For larger files [exec] in combination with"wordcount" works good.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Thu Feb 06, 2003 11:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[digitaldj]]></name></author>
		<updated>2003-02-06T10:55:46-04:00</updated>

		<published>2003-02-06T10:55:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16257#p16257</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16257#p16257"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16257#p16257"><![CDATA[
well, i just thought it maybe was a single command for it or something.. like in mIRC it's just $lines(file.txt)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2491">digitaldj</a> — Thu Feb 06, 2003 10:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-06T10:52:25-04:00</updated>

		<published>2003-02-06T10:52:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16256#p16256</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16256#p16256"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16256#p16256"><![CDATA[
Well, not all the things are simple as they look like.. The usage of the 'foreach' thing is logical to be used. I don't have any ideea (at this moment) of another way to do the same thing. Combining mine and ppslim's reply you should solve this in a sec.. Heh..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Feb 06, 2003 10:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-06T10:41:55-04:00</updated>

		<published>2003-02-06T10:41:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16252#p16252</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16252#p16252"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16252#p16252"><![CDATA[
The foreach command, loops through each line in a list.<br><br>In other words, you have to create a list with the contents of a file. One element for each line.<br><br>For this, you might as well use the "llength" command, which will count for you.<br><br>As noted, you need the list in the first place, as they don't create themselves.<br><br>Use somthing like<br><div class="codebox"><p>Code: </p><pre><code>set lines [llength [split [read [set fp [open "FILE.NAME" w]]] "\n"]]close $fp</code></pre></div>The $lines variable should now contain the number of lines.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Feb 06, 2003 10:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[digitaldj]]></name></author>
		<updated>2003-02-06T10:39:11-04:00</updated>

		<published>2003-02-06T10:39:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16251#p16251</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16251#p16251"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16251#p16251"><![CDATA[
ok.. i knew that, but i thought it might be something more simple..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2491">digitaldj</a> — Thu Feb 06, 2003 10:39 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-06T10:33:55-04:00</updated>

		<published>2003-02-06T10:33:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16250#p16250</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16250#p16250"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16250#p16250"><![CDATA[
Open the file, then use a foreach to increment a number.. Then at the end just extract the value.<br><br>Example of a foreach and incrementation of a value:<br><br>set value 0<br>foreach line $file {<br>incr value<br>}<br><br>Also you may want to see <a href="http://tcl.activestate.com/man/tcl8.2.3/TclCmd/foreach.htm" class="postlink">this</a> page for the 'foreach' and <a href="http://tcl.activestate.com/man/tcl8.2.3/TclCmd/open.htm" class="postlink">this</a> one for the 'open' command..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Feb 06, 2003 10:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[digitaldj]]></name></author>
		<updated>2003-02-06T09:57:35-04:00</updated>

		<published>2003-02-06T09:57:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16246#p16246</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16246#p16246"/>
		<title type="html"><![CDATA[Lines in file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16246#p16246"><![CDATA[
how can i find out how many lines there is in a file? <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2491">digitaldj</a> — Thu Feb 06, 2003 9:57 am</p><hr />
]]></content>
	</entry>
	</feed>
