If you could describe the error in nature, that would certainly help diagnosing the problem. At a quick glance however, it would seem you've forgotten to "escape" some brackets ([]) to prevent command substitution.
Other than that, there are a few code structures that could be a bit "cleaner", but nevertheless they should not hamper the operation of the script...
Did you remember to create a "binding" to trigger the code?
ie:
bind pub myword myproc
Also, "global" is a native tcl command, it would usually be a very bad idea to replace this with your own proc. Most likely you'll break lots of other stuffs. Please consider a different name for your proc (function).
Edit: There also seems to be a variable name mixup regarding the channel argument.
Last edited by nml375 on Mon Nov 24, 2008 10:27 am, edited 1 time in total.
Since everyone else is making a half-hearted attempt at posting slightly modified code, I might just as well post a proper piece of code...
Even so, I still recommend trying to fix the problems yourself based on the hints given, rather than just taking one of the suggested solutions and be done with it.
Oh yeah, at that first glance, I did miss a variable name mixup, which is also fixed...