xces wrote:I have a msg bind. I want the user to do be able to use:
!invite user pass
Code:
set args [split $args]
set usr [lindex $args 0]
set pwd [lindex $args 1]
So i do:
!invite xces test
I get:
$usr = "{xces"
$pwd = "test}"
But i don't need the { and }... how do remove those?
It is because of the special meaning of the word "args". (This question could be added to the FAQ on this forum).
If you have a proc that you want to call with a variable number of arguments, you can use the special reserved word "args".
Code: Select all
# Proc definition using keywords "args"
proc myproc { args } {
set arg0 [lindex $args 0]
set arg1 [lindex $args 1]
...
...
}
# call the proc with one argument
myproc foo
# call the proc with two arguments
myproc foo bar
In your particular case, there is only one argument: the string of text "xces test". To pass this string of text as a list (with one element) to your proc, Tcl embraces it. Thus you get: {xces test}. Then you apply a split command to it, with the result you have shown.
Easiest solution: Do not use the keyword "args", but use something different like "text" or "pubstring".
You can use "args" but then you must treat it as a list having one element: the line of text entered on the channel.