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

	<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-04-05T23:07:20-04:00</updated>

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

		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-04-05T23:07:20-04:00</updated>

		<published>2009-04-05T23:07:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88309#p88309</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88309#p88309"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88309#p88309"><![CDATA[
In pm, Willyw has asked me for help with code for a playback script. ie. a script that will remember the last few chat lines said on a channel and, if commanded to do so, will play back the lines by notice. In reality, this was the reason for the thread in the first place.<br><br>I thought that anybody following the thread may want to play around with and/or improve on the code, so I will paste it here.<br><br>Command syntax is !playback (bot flag o required).<br><br>Lines said by the bot (perhaps due to output from other scripts) are excluded as are !playback command lines.<br><br>The code below is preconfigured to recall the last 5 lines said in the channel #eggTCL.<br><br>Rehash/restart will clear the stored memory.<br><div class="codebox"><p>Code: </p><pre><code># *** configuration *** #set vPlaybackMemory 5set vPlaybackChannel #eggTCL# *** code *** #bind PUB o !playback pPlaybackOutputbind PUBM - * pPlaybackStoreif {[info exists vPlaybackData]} {unset vPlaybackData}proc pPlaybackOutput {nick uhost hand channel txt} {    global vPlaybackData vPlaybackMemory    for {set x 1} {$x &lt;= $vPlaybackMemory} {incr x} {        if {[info exists vPlaybackData($x)]} {puthelp "NOTICE $nick :$vPlaybackData($x)"}    }    return 0}proc pPlaybackPromote {nick channel} {    if {[isop $nick $channel]} {      return "&lt;@$nick\&gt;"    } elseif {[isvoice $nick $channel]} {      return "&lt;+$nick\&gt;"    } else {return "&lt;$nick\&gt;"}}proc pPlaybackStore {nick uhost handle channel txt} {    global vPlaybackChannel vPlaybackData vPlaybackMemory    if {[string equal -nocase $channel $vPlaybackChannel]} {        if {![string match "!playback*" $txt]} {            if {![isbotnick $nick]} {                for {set x 1} {$x &lt; $vPlaybackMemory} {incr x} {                    if {[info exists vPlaybackData([expr {$x + 1}])]} {set vPlaybackData($x) $vPlaybackData([expr {$x + 1}])}                }                set vPlaybackData($vPlaybackMemory) "[pPlaybackPromote $nick $channel] $txt"            }        }    }    return 0}</code></pre></div>If I were to expand on the script, it would be to include other types of channel activity in the memory. ie. joins/parts/actions/modes etc. Outputting the memory automatically onjoin would probably be mega annoying so I avoided doing that.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sun Apr 05, 2009 11:07 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-05T19:31:44-04:00</updated>

		<published>2009-04-05T19:31:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88308#p88308</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88308#p88308"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88308#p88308"><![CDATA[
<blockquote class="uncited"><div>Subst is a command that is used to force variable, command or backslash substitution where it might otherwise fail to occur.<br><br>Take the following example :-<br><br>[00:15] &lt;arfer&gt; .tcl set a one<br>[00:15] &lt;Baal&gt; Tcl: one<br>[00:16] &lt;arfer&gt; .tcl set $a two<br>[00:16] &lt;Baal&gt; Tcl: two<br><br>[00:17] &lt;arfer&gt; .tcl set c $$a<br>[00:17] &lt;Baal&gt; Tcl: $one<br>[00:17] &lt;arfer&gt; .tcl set c [subst $$a]<br>[00:17] &lt;Baal&gt; Tcl: two<br><br>$$a resulted in an unexpected return value. Seemingly the innermost $ did not invoke substitution. This was forced by using subst command, yielding the expected result.</div></blockquote>Thanks for the explanation.   It still makes me do a double take though. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>When you get a free moment, please have a look at your pm inbox here, and let me know what you think of what I'm trying to do.   Again, I suspect there is a better way, but I need direction to get on the right path.<br><br>Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Apr 05, 2009 7:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-04-05T19:22:19-04:00</updated>

		<published>2009-04-05T19:22:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88307#p88307</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88307#p88307"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88307#p88307"><![CDATA[
Subst is a command that is used to force variable, command or backslash substitution where it might otherwise fail to occur.<br><br>Take the following example :-<br><br>[00:15] &lt;arfer&gt; .tcl set a one<br>[00:15] &lt;Baal&gt; Tcl: one<br>[00:16] &lt;arfer&gt; .tcl set $a two<br>[00:16] &lt;Baal&gt; Tcl: two<br><br>[00:17] &lt;arfer&gt; .tcl set c $$a<br>[00:17] &lt;Baal&gt; Tcl: $one<br>[00:17] &lt;arfer&gt; .tcl set c [subst $$a]<br>[00:17] &lt;Baal&gt; Tcl: two<br><br>$$a resulted in an unexpected return value. Seemingly the innermost $ did not invoke substitution. This was forced by using subst command, yielding the expected result.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sun Apr 05, 2009 7:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-04-05T19:15:51-04:00</updated>

		<published>2009-04-05T19:15:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88306#p88306</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88306#p88306"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88306#p88306"><![CDATA[
willy,<br>Sorry, mis-read that line. No need for namespaces then.<br><br>The "[set nick_$nick]" approach of reading the variable should help you avoid the error of "can't read nick_: no such variable".<br>It might be possible to use the upvar trick with 0 level instead of #0, but I have not verified that.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Apr 05, 2009 7:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-05T18:58:59-04:00</updated>

		<published>2009-04-05T18:58:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88305#p88305</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88305#p88305"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88305#p88305"><![CDATA[
<blockquote class="uncited"><div>Just to clarify one thing, that has not been covered in the previous posts...<br><br>You are currently dealing with variables in local namespaces (within the procs). These do not persist inbetween invocations of the proc. What you need to do, ....</div></blockquote>Why?<br><br>I don't  need the variable outside the proc.     Above, I'd said, "...as I intend to unset it at the end of the proc.  "    and now on second thought,  that might not even be necessary.   I hadn't thought of that.<br><br>And thank you for taking time to try to help.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Apr 05, 2009 6:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-05T18:54:52-04:00</updated>

		<published>2009-04-05T18:54:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88304#p88304</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88304#p88304"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88304#p88304"><![CDATA[
<blockquote class="uncited"><div>Just to continue with the thread, the 'normal' way of creating a variable dynamically that is dependent on the value of another variable is to use arrays<br><br>So within the proc above<br><div class="codebox"><p>Code: </p><pre><code>set ar($nick) "beam"</code></pre></div>Much safer. The array named 'ar' now contains an element who's name is equal to the value of the variable named nick (ie. $nick), and this array element has a value "beam". It can be referrenced within the proc using $ar($nick).<br><br>Arrays also lend themselves to some very useful additional Tcl functions.<br><br>For example, if I knew an array element name contained the sequence of characters ARF but didn't know the exact nick it represented (element name)  was arfer or the case was lower, I could find it using something like<br><div class="codebox"><p>Code: </p><pre><code>set name [array names ar -regexp (?i)ARF]</code></pre></div>Declare the array as global within the proc if you wish to use it elsewhere.</div></blockquote><br>I'd seen this somewhere,  already.   It won't work, for what I need... I need it the other way around -   array name corresponding to nick.   Already have all the elements.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Apr 05, 2009 6:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-05T18:51:57-04:00</updated>

		<published>2009-04-05T18:51:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88303#p88303</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88303#p88303"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88303#p88303"><![CDATA[
<blockquote class="uncited"><div>It is the putserv statement that is causing the error, there is nothing wrong with the statement<br><br>set nick_$nick "beam"<br></div></blockquote>Ah!  so it WAS the last line that  I suspected.  Didn't realize the proc was running that far.<br><blockquote class="uncited"><div>Apart from it being rather horrendous code</div></blockquote>It even looked odd to me.  But I was just trying to make minimal changes and trying to watch results, at this point.   <br><blockquote class="uncited"><div>Specifically, it is $nick_$nick that cannot be read. It is not even possible to enclose the name in braces ${nick_$nick} since this prevents the second $ from causing variable substitution.<br><br>I'm not sure if there is a solution to your specific method. I would urge you to reconsider what you are doing and why you are doing it. It is rather like having a variable name containing spaces, in that it generally leads to unnecessary difficulties somewhere down the line.<br></div></blockquote>I'm getting the feeling that I might be going about trying to accomplish the chore with the wrong ideas right from the start.<br>I've sent you a pm, that hopefully explains it.    I hope you don't mind - just didn't want to drag more ugly code out - yet.<br><br><blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>proc atest_proc {nick uhost handle chan text} {set $nick "beam"putserv "privmsg $chan :a variable named $nick has been created with value [subst $$nick]"}</code></pre></div>That code above ought to work but it's very messy. I am beginning to regret answering the original question because this is not something I would do.</div></blockquote>This is new to me - the subst  command.   I've just been to the TCL online manual and looked it up, and I really don't 'get it' yet.<br>I text searched for  $$  to  and it was not on the page - I was hoping to find an example explaining the way you used it.   It was not there. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><br>This has become a side note now - you've made me curious about it.   If there is a better way to get my job done, hopefully you'll be able to point me towards it after reading that explanation.<br><br>Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Apr 05, 2009 6:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-04-05T18:44:00-04:00</updated>

		<published>2009-04-05T18:44:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88302#p88302</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88302#p88302"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88302#p88302"><![CDATA[
Just to clarify one thing, that has not been covered in the previous posts...<br><br>You are currently dealing with variables in local namespaces (within the procs). These do not persist inbetween invocations of the proc. What you need to do, is to store the data in a variable in a global namespace. There are a few ways of doing this, such as using the <strong class="text-strong">global</strong> command, or full namespace paths.<br><br>I'll give you a few examples, which also shows how to handle the issue described by arfer a few posts up...<div class="codebox"><p>Code: </p><pre><code>bind pub - !test atest_proc####### Use global command to link the localspace variable to the globalspace one...proc atest_proc {nick uhost handle chan text} { global "nick_$nick" set nick_$nick "beam" putserv "privmsg $chan :nick_$nick is set to [set nick_$nick]"}####### Use full namespace pathproc atest_proc {nick uhost handle chan text} { set ::nick_$nick "beam" putserv "privmsg $chan :nick_$nick is set to [set ::nick_$nick]"}####### Use the upvar command to link the globalspace variable to "thenick"proc atest_proc {nick uhost handle chan text} { upvar #0 nick_$nick thenick set thenick "beam" putserv "privmsg $chan :nick_$nick is set to $thenick"}####### Use full namespace path along with arraysproc atest_proc {nick uhost handle chan text} { set ::nick_($nick) "beam" puserv "privmsg $chan :nick_($nick) is set to $nick_($nick)"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Apr 05, 2009 6:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-04-05T17:28:59-04:00</updated>

		<published>2009-04-05T17:28:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88301#p88301</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88301#p88301"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88301#p88301"><![CDATA[
Just to continue with the thread, the 'normal' way of creating a variable dynamically that is dependent on the value of another variable is to use arrays<br><br>So within the proc above<br><div class="codebox"><p>Code: </p><pre><code>set ar($nick) "beam"</code></pre></div>Much safer. The array named 'ar' now contains an element who's name is equal to the value of the variable named nick (ie. $nick), and this array element has a value "beam". It can be referrenced within the proc using $ar($nick).<br><br>Arrays also lend themselves to some very useful additional Tcl functions.<br><br>For example, if I knew an array element name contained the sequence of characters ARF but didn't know the exact nick it represented (element name)  was arfer or the case was lower, I could find it using something like<br><div class="codebox"><p>Code: </p><pre><code>set name [array names ar -regexp (?i)ARF]</code></pre></div>Declare the array as global within the proc if you wish to use it elsewhere.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sun Apr 05, 2009 5:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-04-05T16:55:52-04:00</updated>

		<published>2009-04-05T16:55:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88300#p88300</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88300#p88300"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88300#p88300"><![CDATA[
It is the putserv statement that is causing the error, there is nothing wrong with the statement<br><br>set nick_$nick "beam"<br><br>Apart from it being rather horrendous code<br><br>Specifically, it is $nick_$nick that cannot be read. It is not even possible to enclose the name in braces ${nick_$nick} since this prevents the second $ from causing variable substitution.<br><br>I'm not sure if there is a solution to your specific method. I would urge you to reconsider what you are doing and why you are doing it. It is rather like having a variable name containing spaces, in that it generally leads to unnecessary difficulties somewhere down the line.<br><div class="codebox"><p>Code: </p><pre><code>proc atest_proc {nick uhost handle chan text} {set $nick "beam"putserv "privmsg $chan :a variable named $nick has been created with value [subst $$nick]"}</code></pre></div>That code above ought to work but it's very messy. I am beginning to regret answering the original question because this is not something I would do.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sun Apr 05, 2009 4:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-05T16:53:45-04:00</updated>

		<published>2009-04-05T16:53:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88299#p88299</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88299#p88299"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88299#p88299"><![CDATA[
<blockquote class="uncited"><div>You can create a variable with name equal to the value of another variable.<br><br>Say for example I set the value of the variable named testnick ($testnick) to arfer, then use it to create a variable named arfer (with value "my nick").<br><br>[23:23] &lt;arfer&gt; .tcl set testnick arfer<br>[23:23] &lt;osmosis&gt; Tcl: arfer<br>[23:24] &lt;arfer&gt; .tcl set $testnick "my nick"<br>[23:24] &lt;osmosis&gt; Tcl: my nick<br>[23:24] &lt;arfer&gt; .tcl set arfer<br>[23:24] &lt;osmosis&gt; Tcl: my nick<br><br>A new variable was created called arfer, with a value "my nick" as evidenced by the final set command above.</div></blockquote><br>Not ignoring your post.  <br>Thank you very much for replying too.<br>I'm still experimenting with this.     I think I have a mental block or something as it is easy to lose my place when doing this.<br>Will let you know if I get it<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Apr 05, 2009 4:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-05T16:33:19-04:00</updated>

		<published>2009-04-05T16:33:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88298#p88298</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88298#p88298"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88298#p88298"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>*** n is set to "jim"<br>&lt;speechles&gt; .set n "jim"<br>&lt;sp33chy&gt; Ok, set.<br><br>*** nick_jim is set to "beam"<br>&lt;speechles&gt; .set nick_$n "beam"<br>&lt;sp33chy&gt; Ok, set.<br><br>*** show the contents of new variable nick_jim<br>&lt;speechles&gt; .tcl set nick_jim<br>&lt;sp33chy&gt; Tcl: beam</div></blockquote></div></blockquote>Thanks for replying.<br>I'm not there yet.<br><br>Based on your above, and that I want to create the variable based on the nick of the user calling it, I tried this:<div class="codebox"><p>Code: </p><pre><code>bind pub - !test atest_procproc atest_proc {nick uhost handle chan text} {set nick_$nick "beam"putserv "privmsg $chan :  nick_$nick is set to $nick_$nick "}</code></pre></div>with great suspicion about what might happen with the last line.  <br>But I didn't even get that far.<br>When I caused the proc to run,  I get this in partyline:<blockquote class="uncited"><div>Tcl error [atest_proc]: can't read "nick_": no such variable</div></blockquote>Next, just to be sure of typos, etc. ,  I tried this:<div class="codebox"><p>Code: </p><pre><code>proc atest_proc {nick uhost handle chan text} {set n "jim"set nick_$n "beam"putserv "privmsg $chan :  var named nick_$n is set to $nick_$n "}</code></pre></div>and still get<blockquote class="uncited"><div>Tcl error [atest_proc]: can't read "nick_": no such variable</div></blockquote>Isn't that strange?... that it works from the command line, but not in a procedure?<br><br>What do you think?<br><br><blockquote class="uncited"><div>setting an array, just use <em class="text-italics">set arrayname($nick) "something"</em></div></blockquote>Wouldn't that just set an element within the array though?<br>I need the array name to be based on the nick somehow.<br><br><br>Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Apr 05, 2009 4:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-04-04T21:24:14-04:00</updated>

		<published>2009-04-04T21:24:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88292#p88292</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88292#p88292"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88292#p88292"><![CDATA[
<blockquote class="uncited"><div>*** n is set to "jim"<br>&lt;speechles&gt; .set n "jim"<br>&lt;sp33chy&gt; Ok, set.<br><br>*** nick_jim is set to "beam"<br>&lt;speechles&gt; .set nick_$n "beam"<br>&lt;sp33chy&gt; Ok, set.<br><br>*** show the contents of new variable nick_jim<br>&lt;speechles&gt; .tcl set nick_jim<br>&lt;sp33chy&gt; Tcl: beam</div></blockquote>setting an array, just use <em class="text-italics">set arrayname($nick) "something"</em><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sat Apr 04, 2009 9:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-04-04T18:27:31-04:00</updated>

		<published>2009-04-04T18:27:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88290#p88290</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88290#p88290"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88290#p88290"><![CDATA[
You can create a variable with name equal to the value of another variable.<br><br>Say for example I set the value of the variable named testnick ($testnick) to arfer, then use it to create a variable named arfer (with value "my nick").<br><br>[23:23] &lt;arfer&gt; .tcl set testnick arfer<br>[23:23] &lt;osmosis&gt; Tcl: arfer<br>[23:24] &lt;arfer&gt; .tcl set $testnick "my nick"<br>[23:24] &lt;osmosis&gt; Tcl: my nick<br>[23:24] &lt;arfer&gt; .tcl set arfer<br>[23:24] &lt;osmosis&gt; Tcl: my nick<br><br>A new variable was created called arfer, with a value "my nick" as evidenced by the final set command above.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sat Apr 04, 2009 6:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-04-04T15:11:21-04:00</updated>

		<published>2009-04-04T15:11:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88289#p88289</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88289#p88289"/>
		<title type="html"><![CDATA[Create variable name on the fly]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88289#p88289"><![CDATA[
Hello,<br><br>Is there a way to create a variable or array name, based on the nick of the user that called the proc that is using the variable or array?<br><br>Naming the new var   nick-temp  would be ok, as I intend to unset it at the end of the proc.<br><br>I must be overlooking something....<br><br><br>Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sat Apr 04, 2009 3:11 pm</p><hr />
]]></content>
	</entry>
	</feed>
