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 With Wildcards In a loop.

Old posts that have not been replied to for several years.
Locked
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Help With Wildcards In a loop.

Post by CoMMy »

This is my problem.

Code: Select all

foreach binding [binds] {
set bindtype [lindex $binding 0]
set bindattr [lindex $binding 1]
set bindname [lindex $binding 2]
set bindhits [lindex $binding 3]
set bindproc [lindex $binding 4]
if {[string match [string tolower $bindtype] [string tolower msg]]} {
unbind $bindtype $bindattr $bindname $bindproc }}
Where it says [string tolower msg] I want to change msg into
msg_* but it doesnt work.

Can you help me find this?
Basically i want something to select every bind that has a msg_ proc.

Thanks :wink:
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

Anyone?
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
C
Cucumber

Post by Cucumber »

Howdy,

i think you've got your string match params switched. it should be [string match pattern string] and it seems you have [string match string pattern]

also change msg to msg* in your pattern



\\//_
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Instead of using two "string tolower" in a "string match" better use "string equal -nocase" directly. Example:
if {[string equal -nocase $foo $bar]} { # do something }
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Except he's trying to do wildcard matching, so string equal won't work.

Commy, the other problem is that it sounds like you want to match the proc name (msg_*) but the code currently matches bind type (msg, msgm, pub, etc). So you have two things to change.
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

Thanks for that stdragon. I missed it. but code still doesnt work.
It doesnt give out any errors but it doesnt unbind!!!

this is what we have.

Code: Select all

foreach binding [binds] { 
set bindtype [lindex $binding 0] 
set bindattr [lindex $binding 1] 
set bindname [lindex $binding 2] 
set bindhits [lindex $binding 3] 
set bindproc [lindex $binding 4] 
if {[string match [string tolower $bindproc] [string tolower msg_*]]} { 
unbind $bindtype $bindattr $bindname $bindproc }}
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

That was one thing to change, the other is what Cucumber said hehe. You have your arguments mixed up for string match.
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

Thanks man. That did the trick! :P :lol: :mrgreen:
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
Locked