set bans_count 0
foreach bans [banlist $chan] {
# can use -nocase option below if you wish case to be irrelevant
if {[string equal -- [lindex [split $bans] 5] [lindex [split $text] 0]]} {
set bans_count [expr $bans_count + 1]
}
}
if {$bans_count > 0} {
puthelp "NOTICE $nick :Handle \002[lindex [split $text] 0]\002 has $bans_count bans."
} else {
puthelp "NOTICE $nick :Handle \002[lindex [split $text] 0]\002 has \002NO\002 bans."
}
unset bans_count
Without knowing what $bans is to really be doing, as in your code it's serving two purposes?? 1. holding contents of each iteration through the foreach or is it 2. used as a ban counter? It can't do both as your code suggests.
In the code I provided above, they are seperated and correctly handles strings and lists as what they really are. If you want more help than this, you need to better express your needs.
Edit: Haw, corrected the (obvious, thx metroid) bug regarding improper use of markers when setting variables. (set var != set $var.. my bad).
Last edited by speechles on Thu Mar 06, 2008 2:51 pm, edited 3 times in total.
set $bans_count 0
foreach bans [banlist $chan] {
# can use -nocase option below if you wish case to be irrelevant
if {[string equal -- [lindex [split $bans] 5] [lindex [split $text] 0]]} {
set $bans_count [expr $bans_count + 1]
}
}
if {$bans_count > 0} {
puthelp "NOTICE $nick :Handle \002[lindex [split $text] 0]\002 has $bans_count bans."
} else {
puthelp "NOTICE $nick :Handle \002[lindex [split $text] 0]\002 has \002NO\002 bans."
}
unset $bans_count
Without knowing what $bans is to really be doing, as in your code it's serving two purposes?? 1. holding contents of each iteration through the foreach or is it 2. used as a ban counter? It can't do both as your code suggests.
In the code I provided above, they are seperated and correctly handles strings and lists as what they really are. If you want more help than this, you need to better express your needs.