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

	<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-10-22T20:22:00-04:00</updated>

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

		<entry>
		<author><name><![CDATA[ChooChoo]]></name></author>
		<updated>2009-10-22T20:22:00-04:00</updated>

		<published>2009-10-22T20:22:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90612#p90612</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90612#p90612"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90612#p90612"><![CDATA[
thanks for the headsup.<br><br>ill just use another messy hack and use another bot to trigger the function ever 30 seconds <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>thread can be closed.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10921">ChooChoo</a> — Thu Oct 22, 2009 8:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-10-22T20:04:36-04:00</updated>

		<published>2009-10-22T20:04:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90611#p90611</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90611#p90611"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90611#p90611"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc blub {nick uhost hand chan args} {  global running  global break  set parameter [lindex [split $args] 0]  set parameter [string trimleft $parameter "\{"]  set parameter [string trimright $parameter "\}"] </code></pre></div>The above is done incorrectly. In fact every single piece of code above is wrong with the exception of the two global statements.<br><br>The problem is your using the 'special' argument (args) in your procedure header. This is special because it allows that argument to swallow any which may follow it as well as the one in it's place. The result in this case is a list, not a string. If you don't need or understand the function of args, use anything else, arg, text, etc.<br>  <div class="codebox"><p>Code: </p><pre><code>set parameter [lindex [split $args] 0]</code></pre></div>Here you split args, but in this case args is already a list. This will of course cause visible bracings to appear in your output as evidenced by the following two lines:<br>  <div class="codebox"><p>Code: </p><pre><code>set parameter [string trimleft $parameter "\{"]set parameter [string trimright $parameter "\}"] </code></pre></div>Here you make the mistake of using left and right, when [string trim] would've done both at the same time. But the larger mistake is using this at all, as it's a messy hack. If you had chosen something other than 'args' for your procedure header these two lines are not needed and the line above these two would work as intended without them.<br><br>Now on to your question itself. What your asking is can eggdrop do two things at once? The short answer is no. The longer answer is yes, but unfortunately this requires background processes run outside the tcl event engine, and we know these as modules. These run independently of the eggdrop and can interact with it. The module can run and return events to the eggdrop until the eggdrop tells it to stop. So in short, to do what you want, you would need to learn c/c++ and compile your code as a module.<br><br>Note: You can give a pseudo loop like behavior with the use of [timer] or [utimer] and re-invoking them before the procedure they invoke ends. But this requires care and diligence at making sure before you re-invoke them they aren't already running. A rehash/restart can cause several instances to occur, each invoking the procedure to re-invoke themselves. Over time and several rehash/restarts these will cause serious drain on the cpu running your bot. But with careful strategy this could be how you can solve the problem. The second golden rule of tcl can help you regarding timer and utimer. Read about it <a href="http://www.peterre.info/characters.html" class="postlink">here</a>.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Thu Oct 22, 2009 8:04 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ChooChoo]]></name></author>
		<updated>2009-10-22T19:25:37-04:00</updated>

		<published>2009-10-22T19:25:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90610#p90610</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90610#p90610"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90610#p90610"><![CDATA[
thanks, the array stuff worked, didnt thought about that <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>another thing, is it possible to do a endless loop till a channel trigger breaks it?<br><br>my example breakes my eggdrop (he times out)<br><br><div class="codebox"><p>Code: </p><pre><code>set chan "#channel"set blub "!blub"bind pub - $blub blubset running 0set break ""proc blub {nick uhost hand chan args} {  global running  global break  set parameter [lindex [split $args] 0]  set parameter [string trimleft $parameter "\{"]  set parameter [string trimright $parameter "\}"]  if {$parameter ==""} {    putserv "PRIVMSG $chan no Parameter found."  } elseif {$parameter =="start" &amp;&amp; running ==0} {      set running 1        while {break != "stop"} {        do something        after 30000      }    } elseif {$parameter =="stop"} {        global break        set break "stop"        set running 0      } else {          putserv "PRIVMSG $chan wrong parameter"        }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10921">ChooChoo</a> — Thu Oct 22, 2009 7:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-10-22T17:55:41-04:00</updated>

		<published>2009-10-22T17:55:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90609#p90609</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90609#p90609"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90609#p90609"><![CDATA[
<blockquote class="uncited"><div>Sorry Speechless we seem to have been posting simulaneously.<br><br>Out of interest, I don't suppose you could shed any light on this (from the original error) :-<br><br>parse error: missing operator at _@_ in expression "$J&lt;$countzeilen_@_$i<br><br>The _@_ bit in particular. What's that all about?</div></blockquote><div class="codebox"><p>Code: </p><pre><code>for {set j 0} {$j&lt;$countzeilen$i} {incr j} { </code></pre></div>This is assumption, but probably a correct assumption. The problem is the middle part of the for loop ({$j&lt;$countzeilen$i}) is treated as if it were an [expr] command. Same as using an if statement as it is also treated as an expr. As such, since you mash two variables together, the expr command is confused about this. It thinks there should be an operator (+ - etc) placed between the variables and uses the _@_ to signify the spot where it thinks this should be. This is why that method of scripting is difficult (and as you mentioned messy), because embedding variables of this type into an expr always results in the same error regarding missing operators (searching the forums for _@_ you will see scripts that use this method fail when commands which base their logic on expressions are used. The best way to acheive this is use the tools tcl gives you and base your expressions around arrays. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>Upon reading up on this, appears my thinking was indeed correct.<blockquote class="uncited"><div>In Tcl syntax yes, but expr has its own little language, where some<br>things are different:<br><br>% set a 1; set b 2<br>2<br>% expr $a$b+3<br>15<br>% expr {$a$b+3}<br>missing operator at _@_<br>in expression "$a_@_$b+3"</div></blockquote>It appears when using these commands, they enclose the expr within braces (to prevent exploits of course) and this causes this scenario.<blockquote class="uncited"><div>On the other hand, you can use "" to force string concatenation in the<br>middle of an expression:<br><br>% expr {"$a$b"+3}<br>15</div></blockquote>But appears you can avoid this by enclosing your mashed together variables within double quotes.. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Thu Oct 22, 2009 5:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-22T17:36:13-04:00</updated>

		<published>2009-10-22T17:36:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90608#p90608</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90608#p90608"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90608#p90608"><![CDATA[
Sorry Speechless we seem to have been posting simulaneously.<br><br>Out of interest, I don't suppose you could shed any light on this (from the original error) :-<br><br>parse error: missing operator at _@_ in expression "$J&lt;$countzeilen_@_$i<br><br>The _@_ bit in particular. What's that all about?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Thu Oct 22, 2009 5:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-22T17:27:26-04:00</updated>

		<published>2009-10-22T17:27:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90607#p90607</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90607#p90607"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90607#p90607"><![CDATA[
It does not ignore the $i. When trying to concatenate the value of the variable countzeilen with the value of the variable i, it is saying that the variable countzeilen does not exist, which is true.<br><br>Though I can now see what you are getting at. You wish to use the for loop to form the three variable names countzeilen0 countzeilen1 and countzeilen2 and then access their values.<br><br>Potentially I think that coding in this manner can get very messy, my suggestion would be to start thinking of using arrays.<br><br>If you have the array variable countzeilen with say elements countzeilen(0), countzeilen(1) and countzeilen(2) etc then their name/value pairs can be accessed using :-<br><div class="codebox"><p>Code: </p><pre><code>foreach {name value} [array get countzeilen] {    # code here using $name and/or $value}</code></pre></div>Or you could set the value of an array element using another variable value as the element name :-<br><div class="codebox"><p>Code: </p><pre><code>set countzeilen($i) "whatever"</code></pre></div>Although Tcl arrays can only be one dimentional, you can quite easily emulate multidimensional arrays using something like the following :-<br><div class="codebox"><p>Code: </p><pre><code>set countzeilen(${i},$j) "whatever"</code></pre></div>Providing the variable i exists in the first example, or both i and j in the second then the code if fine.<br><br>I would urge you to reconsider your logic.<br><br>Otherwise, building a variable name from other strings and/or variable values, then accessing or setting the built variable value may well require the use of $$. Like I said, messy. Though sometimes possible, with care. I would not use the logic you were originally intending to use.<br><br>If you explain more completely what you are trying to do, I will try to help further.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Thu Oct 22, 2009 5:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-10-22T17:17:31-04:00</updated>

		<published>2009-10-22T17:17:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90606#p90606</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90606#p90606"/>
		<title type="html"><![CDATA[Re: Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90606#p90606"><![CDATA[
<blockquote class="uncited"><div>Hi,<br><div class="codebox"><p>Code: </p><pre><code>for {set i 0} {$i&lt;3} {incr i} {   for {set j 0} {$j&lt;$countzeilen$i} {incr j} {      set zeile$i$j [string trim $zeile$i$j ":"]   }}</code></pre></div>the problem is a puttogether variable "$countzeile$i" is not allowed, how can i fix it with the right syntax?<br><br>also, same problem with the puttogether [string trim...]<br><br>thanks in advance.</div></blockquote>Why not use an array? It's much simpler.<div class="codebox"><p>Code: </p><pre><code>for {set i 0} {$i&lt;3} {incr i} {   for {set j 0} {$j&lt;$countzeilen($i)} {incr j} {      set zeile($i,$j) [string trim $zeile($i,$j) ":"]   }}</code></pre></div>Notice how much more readable it looks this way? <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br>As arfer said, have no idea what the intention of this is, but using arrays will make it easier on your head.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Thu Oct 22, 2009 5:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ChooChoo]]></name></author>
		<updated>2009-10-22T16:51:04-04:00</updated>

		<published>2009-10-22T16:51:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90605#p90605</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90605#p90605"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90605#p90605"><![CDATA[
thx for the reply.<br><br>there are 3 vars countzeilen0 , countzeilen1, countzeilen2 each containing a number.<br><br>if i &lt; countzeilen0<br>if i &lt; countzeilen1<br>.....<br><br><br>the tempstuff is not working :<br><br>set temp $countzeilen$i<br>for {set j 0} {$j&lt;$temp} {incr j} { <br><br>Tcl error [tsharing]: can't read "countzeilen": no such variable<br><br>because he ignores the $i <br>he does "set temp countzeilen" <br>and not "set temp countzeilen0"<br><br><br>and version #2<br><br>for {set j 0} {$j&lt;[join $countzeilen$i]} {incr j} { <br><br>does the same <br>Tcl error [tsharing]: can't read "countzeilen": no such variable<br><br><br>edit : <br>about the trim<br><br>there are 3 * x vars (x = countzeilen)<br>zeile00 = "string with : : :"<br>zeile10 = "string with : : :"<br>zeile20 = "string with : : :"<br><br>till<br><br>zeile0x where x = countzeilen0 "containting a string with some :"<br>zeile1x where x = countzeilen1 "containting a string with some :"<br>zeile2x where x = countzeilen2 "containting a string with some :"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10921">ChooChoo</a> — Thu Oct 22, 2009 4:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-22T15:39:11-04:00</updated>

		<published>2009-10-22T15:39:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90603#p90603</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90603#p90603"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90603#p90603"><![CDATA[
I see what you mean regarding :-<br><div class="codebox"><p>Code: </p><pre><code>for {set j 0} {$j&lt;$countzeilen$i} {incr j} {</code></pre></div>It yields a strange looking error in my editor while being parsed :-<br><br>parse error: missing operator at _@_ in expression "$J&lt;$countzeilen_@_$i<br><br>You could try throwing in a command that causes the variable values to be concatenated before being used in the logical test, such as :-<br><div class="codebox"><p>Code: </p><pre><code>for {set j 0} {$j&lt;[join $countzeilen$i]} {incr j} {</code></pre></div>Or, create a temporary variable :-<br><div class="codebox"><p>Code: </p><pre><code>set temp $countzeilen$ifor {set j 0} {$j&lt;$temp} {incr j} {</code></pre></div>As for :-<br><div class="codebox"><p>Code: </p><pre><code>set zeile$i$j [string trim $zeile$i$j ":"]</code></pre></div>I see nothing syntactically wrong with this statement, as long as the variable named zeile already exists.<br><br>This is not to say whether or not the code actually does what you expect. I can't really comment on that since i don't know what you expect.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Thu Oct 22, 2009 3:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ChooChoo]]></name></author>
		<updated>2009-10-22T12:06:45-04:00</updated>

		<published>2009-10-22T12:06:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90601#p90601</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90601#p90601"/>
		<title type="html"><![CDATA[Variable setting problems]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90601#p90601"><![CDATA[
Hi,<br><div class="codebox"><p>Code: </p><pre><code>             for {set i 0} {$i&lt;3} {incr i} {               for {set j 0} {$j&lt;$countzeilen$i} {incr j} {                 set zeile$i$j [string trim $zeile$i$j ":"]               }             }</code></pre></div>the problem is a puttogether variable "$countzeile$i" is not allowed, how can i fix it with the right syntax?<br><br>also, same problem with the puttogether [string trim...]<br><br>thanks in advance.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10921">ChooChoo</a> — Thu Oct 22, 2009 12:06 pm</p><hr />
]]></content>
	</entry>
	</feed>
