im only quite new to tcl scripting, and i want to set a switch to use as variables within a proc. im not too sure how to do this properly, so if someone could just give me a quick example.
on command in channel !select, i want to use a switch to give me a variable number. so the line in a channel would be:
!select --n20 rest of the text string here
i want to use whatever number after --n as the variable to use in the rest of the proc, and i need the rest of the text string in a variable too.
bind pub - !select pub:select
proc pub:select {nick uhost hand chan arg} {
# --n#
set switch [lindex [split $arg] 0]
# if switch is not --n<number> then return
if {![regexp -- {--n[0-9]{1,}} $switch]} {return 0}
# take the number after --n
set num [string range $switch 3 end]
# take the rest
set rest [join [lrange [split $arg] 1 end]]
switch -- $num {
1 {
# the number is 1, do whatever
}
2 {
# the number is 2, do whatever
}
default {
# any other number
}
}
}