I'm new in the world of TCL and i'm reading tips section of this forum as well as different documents/tutorials as well to learn tcl language. Now i'm trying to study different scripts to understand the codes. This forum is the best source and a lot of good coders are here to help the users. I chose 2 excellent excellent scripts for my study to understand the codes:
1: xchannel by demond
2: allprotection by Sir_Fz
I've started xchannel first and i've some silly questions and i hope someone will be able to explain them. Also i think this thread will help other new comers like me as well.
I would appreciate if someone would explain these codes please, i do understand a bit but still confused. this procedure -> proc fixargs {chan text args} is called from all other procedures like for example:
Code: Select all
proc repeat {nick uhost hand chan args} {
variable repeats
fixargs chan text $args
...............
Code: Select all
proc fixargs {chan text args} {
upvar $chan xchan; upvar $text xtext
if {$::lastbind == "**"} {
set xtext $xchan
set xchan [lindex $args 0]
} {
set n [llength $args]
set xtext [lindex $args [incr n -1]]
}
}
and what's the purpose to have upvar here in the procedure and what's the benefit?
2:
I understood this procedure
Code: Select all
proc maskhost {nuhost {type 0}} {
scan $nuhost {%[^!]!%[^@]@%s} nick user host
scan [set mask [::maskhost $nuhost]] {%*[^@]@%s} mhost
switch $type {
0 - 1 {return $mask} ;# *!*foo@*.bar.com
2 {return *!*@$host} ;# *!*@moo.bar.com
3 {return *!*@$mhost} ;# *!*@*.bar.com
4 {return *!*$user@$host} ;# *!*foo@moo.bar.com
5 {return *!*$user@*} ;# *!*foo@*
6 {return $nuhost}
}
}
Code: Select all
set hash [md5 $chan:$what:[maskhost $nick!$uhost]]
I think for now its enough for me to digest all this.
Thank you
regards
-timt