This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

variable inside set variable command? [Solved]

Help for those learning Tcl or writing their own scripts.
Post Reply
b
bradleylauchlin
Voice
Posts: 6
Joined: Mon Apr 14, 2008 8:02 pm

variable inside set variable command? [Solved]

Post by bradleylauchlin »

Is it possible to use a variable inside a set command?

I have a bot that is in about 10 channels that I am using. I want it to record a certain piece of information on that channel. That is working, however the problem I am facing is that if it is set on antoehr channel, it becomes the same for ALL channels. I could just make it a different proc for each of the 10 channels, however I want to be able to scale this out to more channels as needed, and it would be a lot of work once it gets bigger.

Is there anyway to use something like the following?

global record_$chan
set record_$chan

So if the channel name was test the variable it was actually using would be record_test

Let me know if anyone knows the way to pull this off.
THanks :)
Last edited by bradleylauchlin on Sat Apr 19, 2008 10:35 pm, edited 1 time in total.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: variable inside set variable command?

Post by speechles »

Code: Select all

global records
set records($chan) "etc"
Arrays can easily accomplish this. A single global variable array is better than a multitude of seperate global strings floating around.
b
bradleylauchlin
Voice
Posts: 6
Joined: Mon Apr 14, 2008 8:02 pm

Duh

Post by bradleylauchlin »

Yeah, I hadn't even thought about arrays (/me slams forehead on desk). Of course. Thanks for the help :)
Post Reply