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

	<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-08-29T06:06:43-04:00</updated>

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

		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T06:06:43-04:00</updated>

		<published>2003-08-29T06:06:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25903#p25903</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25903#p25903"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25903#p25903"><![CDATA[
<blockquote class="uncited"><div>like i said before, my shells are down<br>i have no way of testing this.</div></blockquote>like i said before, get tclsh running on your local machine <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><blockquote class="uncited"><div>do you think this would work?<br>...</div></blockquote>This is how my previous proc works...'gets' reads every byte from the current position in the file to the next newline (or the end of the file, whichever comes first). So each call to 'gets' will cause the access position in the file channel to be moved one line further towards the end of the file.<br><br>You just increase the counter but do nothing to the access position in the file channel, so your code will always give you the first line from the file. (because you only 'gets' once)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 6:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T05:54:04-04:00</updated>

		<published>2003-08-29T05:54:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25902#p25902</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25902#p25902"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25902#p25902"><![CDATA[
like i said before, my shells are down<br>i have no way of testing this.<br><br>do you think this would work?<br><div class="codebox"><p>Code: </p><pre><code>  set line ""  set line_wanted 75  if {[file exists $my_file]} {    set opened_file [open $my_file r]    set line_number 0    while {![eof $opened_file]} {      incr line_number 1      if {$line_number == $line_wanted} {        set line [gets $opened_file]        break      }    }    if {$line == ""} {      *** error message ***    }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 5:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T05:45:36-04:00</updated>

		<published>2003-08-29T05:45:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25901#p25901</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25901#p25901"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25901#p25901"><![CDATA[
<blockquote class="uncited"><div>this file has about 2500 lines, is there anyway<br>to get aroung reading all those lines?</div></blockquote>If the contents is fairly static you could compile some sort of index...eg. a list of line lengths (this way you could skip directly to the desired line using 'seek')<br><br>Here's a proc reading the file line by line rather than reading it all and splitting it (sort of like mirc does it internally i'd imagine):<br><div class="codebox"><p>Code: </p><pre><code>proc getLine {file {line 1}} {set f [open $file]set i 0while {[incr i]&lt;$line} {gets $f}gets $f lineclose $fset line}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 5:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T05:03:34-04:00</updated>

		<published>2003-08-29T05:03:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25900#p25900</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25900#p25900"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25900#p25900"><![CDATA[
this file has about 2500 lines, is there anyway<br>to get aroung reading all those lines?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 5:03 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T04:58:28-04:00</updated>

		<published>2003-08-29T04:58:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25899#p25899</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25899#p25899"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25899#p25899"><![CDATA[
<blockquote class="uncited"><div>ok, so the command is:<br><br>{getLineIfItExists $opened_file $line_wanted}<br><br>??????</div></blockquote>Yup..lose the braces though <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> (and feel free to rename the proc ;P)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 4:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T04:41:52-04:00</updated>

		<published>2003-08-29T04:41:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25898#p25898</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25898#p25898"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25898#p25898"><![CDATA[
ok, so the command is:<br><br>{getLineIfItExists $opened_file $line_wanted}<br><br>??????<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 4:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T04:03:50-04:00</updated>

		<published>2003-08-29T04:03:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25897#p25897</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25897#p25897"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25897#p25897"><![CDATA[
<blockquote class="uncited"><div>I am overwhelmed by the commands of tcl to deal with files, are you saying that there is no way to read a certain line <br>without knowing its lenght?</div></blockquote>I can see why you're intimidated by this as you're used to mirc's file commands. Tcl deals with files like real programming languages; you get full control at the cost of a bit more coding work. There are no lines in a file, only bytes. :^)<br><blockquote class="uncited"><div>In your last proc you showed no way to retrevie the line<br>so it could be set.</div></blockquote>Let me repeat with comments <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><div class="codebox"><p>Code: </p><pre><code>proc getLineIfItExists {file {line 0}} {    # this first line does alot of stuff...   # first the file is opened for reading (the default mode, so the "r" is not needed   # then the file pointer returned is stored in the variable "file"   # set returns the value further up to 'read' which reads the entire file   # and returns the contents to 'split' which chops it up by the newlines (\n)   # the resulting list of lines is then stored in 'lines'   set lines [split [read [set file [open $file]]] \n]    # then the file is closed (as we don't need to read from it no more)   close $file    # and THEN we check if the number of lines is &gt; our desired line #   if {[llength $lines]&gt;$line} {       # if it is, we retrieve the line we want using lindex (this value is then returned by the proc...you could of course store it in a variable or what ever you might desire      lindex $lines $line    } else {      # if the requested line number is too high, generate an error.      error "No such line: $line"    } }</code></pre></div> <br><br>Did that make things clear? <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=2878">user</a> — Fri Aug 29, 2003 4:03 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T03:34:25-04:00</updated>

		<published>2003-08-29T03:34:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25896#p25896</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25896#p25896"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25896#p25896"><![CDATA[
I am overwhelmed by the commands of tcl to deal with files, <br>are you saying that there is no way to read a certain line <br>without knowing its lenght?<br><br>In your last proc you showed no way to retrevie the line<br>so it could be set.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 3:34 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T03:19:47-04:00</updated>

		<published>2003-08-29T03:19:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25895#p25895</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25895#p25895"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25895#p25895"><![CDATA[
<blockquote class="uncited"><div>do you think this might work?</div></blockquote>'info exists' is for checking for the existance of variables. 'seek' is for changing the position in a open file and works with bytes, not lines, so unless your file contains only newlines this doesn't make any sense.<br><br>The only way to make it work using seek is by having fixed line lengths.<br><br><br>Tip: Install tclsh (tcl shell) on your current computer to test suff in.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 3:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T03:12:37-04:00</updated>

		<published>2003-08-29T03:12:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25894#p25894</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25894#p25894"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25894#p25894"><![CDATA[
both my shell accounts are down,<br>I have no way to test this.<br><br>do you think this might work?<br><div class="codebox"><p>Code: </p><pre><code>  set line_wanted 75  if {[file exists $my_file]} {    set opened_file [open $my_file r]    if {[info exists [seek opened_file 75 start]]} {      set found_line [seek opened_file 75 start]    }  }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 3:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T03:00:13-04:00</updated>

		<published>2003-08-29T03:00:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25893#p25893</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25893#p25893"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25893#p25893"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc getLineIfItExists {file {line 0}} {set lines [split [read [set file [open $file]]] \n]close $fileif {[llength $lines]&gt;$line} {lindex $lines $line} else {error "No such line: $line"}}</code></pre></div>EDIT: there was an error in the first proc i pasted...it's been corrected now<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 3:00 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T02:53:43-04:00</updated>

		<published>2003-08-29T02:53:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25892#p25892</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25892#p25892"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25892#p25892"><![CDATA[
ok, forget the index suggestion and please answer this:<br><br>I want to retrive a certain line from a file and place it in a var.<br><br>only 1 line<br><br>In the script below i want to do 2 things:<br>1) test if there is a line 75<br>2) if so, then retrieve and place it in a var<br><div class="codebox"><p>Code: </p><pre><code>  set line_wanted 75  if {[file exists $my_file]} {    set opened_file [open $my_file r]    need to check if line exsist    need to retrive line    set found_line   ??????</code></pre></div>thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 2:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T02:26:44-04:00</updated>

		<published>2003-08-29T02:26:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25889#p25889</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25889#p25889"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25889#p25889"><![CDATA[
<blockquote class="uncited"><div>what is the "%" and the space for?</div></blockquote>% matches 0 or more non-space characters (can be used to match a single word) ...and in a pubm bind the mask is matched against the channel name followed by the text, so the % is used to match any channel name. (you could have used *, but then you'd risk matching things that doesn't start with the trigger)<br><br>(all this info can be found in doc/tcl-commands.doc)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 2:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dedan]]></name></author>
		<updated>2003-08-29T02:21:10-04:00</updated>

		<published>2003-08-29T02:21:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25888#p25888</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25888#p25888"/>
		<title type="html"><![CDATA[index marker in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25888#p25888"><![CDATA[
user wrote:<blockquote class="uncited"><div> bind pubm -|- "% !p*" que:poem </div></blockquote>what is the "%" and the space for?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3472">Dedan</a> — Fri Aug 29, 2003 2:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-08-29T00:49:32-04:00</updated>

		<published>2003-08-29T00:49:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=25884#p25884</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=25884#p25884"/>
		<title type="html"><![CDATA[Back on topic]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=25884#p25884"><![CDATA[
<blockquote class="uncited"><div>The channel commands will be like !p1 or !p25 or !p37</div></blockquote>Then I suggest using a mask that will match those triggers:<div class="codebox"><p>Code: </p><pre><code>bind pubm -|- "% !p*" que:poem</code></pre></div>Btw: Good luck finding your answers in this thread  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_lol.gif" width="15" height="15" alt=":lol:" title="Laughing"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Fri Aug 29, 2003 12:49 am</p><hr />
]]></content>
	</entry>
	</feed>
