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

	<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>2010-08-13T13:35:07-04:00</updated>

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

		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2010-07-29T03:08:59-04:00</updated>

		<published>2010-07-29T03:08:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93684#p93684</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93684#p93684"/>
		<title type="html"><![CDATA[problem matching indexes in file lines [solved]]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93684#p93684"><![CDATA[
If the "database" is not too heavy, a good way is to read once the file and store it in an array, so you can easily answer to ?word without re-open and re-read the file.<br>And you can also immediatly check if the word already exists in the array.<br><br>Thats what I use in my jokes.tcl (only in reading) :<div class="codebox"><p>Code: </p><pre><code>proc joke:load {} {    set jp [open $::jname "r"]    set jdata [read -nonewline $jp]    close $jp    set ::j_list ""    foreach templine [split $jdata "\n"] {        set joke_line [split $templine "="]        set jkey [string tolower [lindex $joke_line 0]]        if {[string index $jkey 0] == "!"} {            set jkey [string range $jkey 1 end]        } else {            lappend ::j_list [string tolower $jkey]        }        set ::joke_key_gen($jkey) [lindex $joke_line 1]        set ::joke_key($jkey) [lindex $joke_line 2]        bind pub - ":$jkey*" joke:display    }}joke:load</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Thu Jul 29, 2010 3:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2010-07-27T23:45:28-04:00</updated>

		<published>2010-07-27T23:45:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93682#p93682</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93682#p93682"/>
		<title type="html"><![CDATA[problem matching indexes in file lines [solved]]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93682#p93682"><![CDATA[
<img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile">   You are welcome.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Tue Jul 27, 2010 11:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Luminous]]></name></author>
		<updated>2010-07-27T23:44:24-04:00</updated>

		<published>2010-07-27T23:44:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93681#p93681</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93681#p93681"/>
		<title type="html"><![CDATA[problem matching indexes in file lines [solved]]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93681#p93681"><![CDATA[
Wow, so simple...   haha, usually is. Thanks man.. <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=11101">Luminous</a> — Tue Jul 27, 2010 11:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2010-07-27T23:18:24-04:00</updated>

		<published>2010-07-27T23:18:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93679#p93679</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93679#p93679"/>
		<title type="html"><![CDATA[problem matching indexes in file lines [solved]]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93679#p93679"><![CDATA[
Examine:<div class="codebox"><p>Code: </p><pre><code>add {set fs [open "shortcuts.txt"]set data [split [read -nonewline $fs] \n]set check [join [lindex [split $text] 1]]while {[gets $fs line] &gt;= 0} {</code></pre></div>that section first.<br><br>The file is open, and I suspect the read command has left the file access at the very end of the file.<br>When you use gets , I think you mean to use it from the beginning of the file.<br><br>Thus,  try inserting this line:<div class="codebox"><p>Code: </p><pre><code>seek $fs 0 start</code></pre></div>just before your while line.<br><br>I hope this helps.<br><br>reference: <br><a href="http://www.tcl.tk/man/tcl8.5/TclCmd/seek.htm" class="postlink">http://www.tcl.tk/man/tcl8.5/TclCmd/seek.htm</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Tue Jul 27, 2010 11:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Luminous]]></name></author>
		<updated>2010-08-13T13:35:07-04:00</updated>

		<published>2010-07-27T21:27:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93678#p93678</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93678#p93678"/>
		<title type="html"><![CDATA[problem matching indexes in file lines [solved]]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93678#p93678"><![CDATA[
So, I have here, a mostly complete shortcut proc, so users can do like ~cs add word definition. To use it, they simply envoke ?word and get "definition". Problem is, I have no way to make sure the word they give doesn't already exist in the file. Every combination of while {[gets..., foreach, regex and string trim have failed.<br><br>There are two parts I need this kind of functionality: in the add { switch and then again in the list { switch section. They differ slightly, but I need a way to match only against the first element in $line. <br><br>Problem #2. For some reason, the while {[gets $fs line] &gt;= 0} { line in add { switch does not loop through each line. I tried to make it notice me each line, but it would not. The one is list { is nearly identical, and it will at least notice me properly. But i also need that section to check index one of each line to see if it exists. if so, display 1 end. <br><br><a href="http://paste.tclhelp.net/?id=7dr" class="postlink">http://paste.tclhelp.net/?id=7dr</a><br><br>Help is appreciated. :)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11101">Luminous</a> — Tue Jul 27, 2010 9:27 pm</p><hr />
]]></content>
	</entry>
	</feed>
