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.
Help for those learning Tcl or writing their own scripts.
Justdabomb2
Voice
Posts: 37 Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America
Post
by Justdabomb2 » Sun Nov 12, 2006 11:22 am
I want to make a bind that will respond to any number between 0 and $number. How would I do that?
Thanks
Yeah!
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun Nov 12, 2006 11:43 am
What kind of bind? where is the "number" coming from?
Justdabomb2
Voice
Posts: 37 Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America
Post
by Justdabomb2 » Sun Nov 12, 2006 11:48 am
The number would be set earlier in the script (DUUUH). and it would be a pub or pubm.
Yeah!
rosc2112
Revered One
Posts: 1454 Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania
Post
by rosc2112 » Sun Nov 12, 2006 1:22 pm
You'd use a "for" or a "while" and increment a count-var.
Justdabomb2
Voice
Posts: 37 Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America
Post
by Justdabomb2 » Sun Nov 12, 2006 2:20 pm
show me how!.... pleasse
Yeah!
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sun Nov 12, 2006 5:02 pm
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
Justdabomb2
Voice
Posts: 37 Joined: Fri Sep 29, 2006 7:16 pm
Location: United States of America
Post
by Justdabomb2 » Sun Nov 12, 2006 7:59 pm
yeah, I thought of that, but how would I do that...ince the numbers can range between 10,000
Yeah!
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sun Nov 12, 2006 10:29 pm
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