This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

How do I make a bind mask to a set range of numbers?

Help for those learning Tcl or writing their own scripts.
Post Reply
J
Justdabomb2
Voice
Posts: 37
Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America

How do I make a bind mask to a set range of numbers?

Post by Justdabomb2 »

I want to make a bind that will respond to any number between 0 and $number. How would I do that?

Thanks
Yeah!
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

What kind of bind? where is the "number" coming from?
J
Justdabomb2
Voice
Posts: 37
Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America

Post by Justdabomb2 »

The number would be set earlier in the script (DUUUH). and it would be a pub or pubm.
Yeah!
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

You'd use a "for" or a "while" and increment a count-var.
J
Justdabomb2
Voice
Posts: 37
Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America

Post by Justdabomb2 »

show me how!.... pleasse
Yeah!
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Modify to suit your needs:

Code: Select all

for {set i 0} {$i < $number} {incr i} {
 bind pub - $i yourproc
}
I'd suggest however you keep $number relatively small, since you're creating one new binding per number between 0 and $number. (the only other option would be to use a pubm-binding with "*" as mask and then check wether it's a number or not within the proc itself...)
NML_375
J
Justdabomb2
Voice
Posts: 37
Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America

Post by Justdabomb2 »

yeah, I thought of that, but how would I do that...ince the numbers can range between 10,000
Yeah!
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

One way of doing it, using regular expressions...

Code: Select all

bind pubm - * the_proc
proc the_proc {nick host handle channel text} {
 if {[regexp -- {^[[:digit:]]+$} $text]} {
  #$text was a number
 } {
  #$text was not a number
 }
}
NML_375
Post Reply