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

	<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>2002-08-14T07:08:04-04:00</updated>

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

		<entry>
		<author><name><![CDATA[slashem]]></name></author>
		<updated>2002-08-14T07:08:04-04:00</updated>

		<published>2002-08-14T07:08:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=9751#p9751</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=9751#p9751"/>
		<title type="html"><![CDATA[replacing words..?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=9751#p9751"><![CDATA[
thx for the tip..<br>used:<div class="codebox"><p>Code: </p><pre><code>              if { $found == "1" } {                  set newstring [join [lreplace $list2 0 1 [lindex $list1 2] [lindex $list1 2]]]                  putserv "PRIVMSG $chan :$newstring"</code></pre></div>now, and that works <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=1742">slashem</a> — Wed Aug 14, 2002 7:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-08-14T05:12:56-04:00</updated>

		<published>2002-08-14T05:12:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=9745#p9745</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=9745#p9745"/>
		<title type="html"><![CDATA[replacing words..?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=9745#p9745"><![CDATA[
That is because you are working with strings, but using list based commands. You should use [split] before using lreplace.<br><br>And [join] at the end, to turn the list back into a string.<br><br>As for your mIRC adiction, I would refer you to <a href="http://forum.egghelp.org/viewtopic.php?t=1341" class="postlink">here</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Wed Aug 14, 2002 5:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[slashem]]></name></author>
		<updated>2002-08-13T18:50:49-04:00</updated>

		<published>2002-08-13T18:50:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=9735#p9735</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=9735#p9735"/>
		<title type="html"><![CDATA[replacing words..?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=9735#p9735"><![CDATA[
Hiya..<br>I have a txtfile with on each line a few words like:<br>BLUB BLUB ONE TWO<br>BLUB OTHER WORDS<br>..<br>there are a few of these lines.. every odd line contains 2x BLUB (or another word twice), every even line 1x BLUB (or again another word).<br><br>I'm trying to make an mirc trigger that will rename BLUB BLUB into for example BLUB2 BLUB2<br><br>the trigger and the amount of arguments with the trigger is not a problem..<br>the problem is with lists and strings.<br>I can find the word BLUB in the lines but when I use lreplace to replace the words, the entire string becomes {BLUB2 BLUB2 ONE TWO}<br>&lt;- adds those brackets..<br>when I use lappend it becomes BLUB2 BLUB2 {ONE TWO}<br><br>I'll pase a piece of the code here:<div class="codebox"><p>Code: </p><pre><code>   if {[lindex $list1 0] == "sname" } {       set fs [open blub.txt r+]       set found 0       while {![eof $fs]} {           set newstring ""           gets $fs line           set list2 [split $line]           if { "[lindex $list2 0]" == "[lindex $list1 1]" } {              incr found              if { $found == "1" } {                  lappend newstring [lindex $list1 2]                  lappend newstring [lindex $list1 2]                  lappend newstring [lrange $list2 2 [expr [llength $list2] -1] ]                  putserv "PRIVMSG $chan :$newstring"               }               if { $found == "2" } {                lappend newstring [lreplace $list2 0 0 [lindex $list1 2]]                #putserv "PRIVMSG $chan :[lreplace $list2 0 0 [lindex $list1 2]]"                              }</code></pre></div>$list1 contains the vars of the trigger.. would be called from mirc with <strong class="text-strong">!set sname BLUB BLUB</strong><br>$list2 contains a list of the words in the line that was read from the textfile.<br>I compare the word BLUB from the trigger with the first word from each line in the textfile ( if { "[lindex $list2 0]" == "[lindex $list1 1]" } { )<br>lindex $list2 0 = that first word..<br><br>since there are only two lines with that BLUB on it I used $found here with 0 as start value and 1, 2 for when it is found.. cuz the first time it needs to to two replacements, the second time only one.<br><br>the three lappend's for when $found == "1" could also be written as:<div class="codebox"><p>Code: </p><pre><code>                  lreplace $list2 [lindex $list2 0] [lindex $list1 1]                  lreplace $list2 [lindex $list2 1] [lindex $list1 1] </code></pre></div>the main difference is: with lappend I get BLUB2 BLUB2 {ONE TWO}<br>with lreplace {BLUB2 BLUB2 ONE TWO} <br><br>NOW, I wanna get rid of these annoying brackets {} <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>I have to mention that I'm a total n00b with tcl.. just started today, but have learned a lot already today and it's cool:)<br><br>thx in advance to anyone who can and is willing to help me out<br><br>greetz<br>Slashem<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1742">slashem</a> — Tue Aug 13, 2002 6:50 pm</p><hr />
]]></content>
	</entry>
	</feed>
