Actually, if you use "args" as the last argument in a proc-definition, it is guaranteed to be a valid tcl-list, with one item for each parameter (if any) supplied (when the proc is invoked).
Using lassign should not alter the scope of the source, as this is expected to be a list, not a variable containing a list.
The scope of the variables set by lassign depends on the names you provide with the command; do they include any namespace paths? (::myvar ::somespace::myvar), is the variable linked to a different execution level using upvar or global?, and so on.
Regarding your code; I doubt that does what you intended; $args would never be equal to the string "4". You should use the llength command to get the length of the list. Also, VarA is not set prior either "set $VarA" lines, causing an error. I assume you actually intended to set a value to the variable VarA, not a variable named by the contents of VarA (remove the $-sign).
Code: Select all
bind pub - !test command
bind msg - !test command
proc command {nick args} {
set arg [lindex $args end]
if {[llength $args] == 4} {
#Triggered by the pub-binding
set VarA {PRIVMSG}
} else {
#Triggered by the msg-binding
set VarA {NOTICE}
}
putquick "$VarA $nick :Command Successful! you said $arg"
}