mIRC Home    About    Download    Register    News    Help

Print Thread
wildcard hfind with search pattern in string/var #266211 21/10/19 07:52 AM
Joined: Jul 2007
Posts: 53
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 53
I'm trying to do a wildcard search using $hfind, where the search pattern is stored in a string or a variable but I can't get it to work. I did find a post (https://forums.mirc.com/ubbthreads.php/topics/260913/how-to-use-a-wildcard-pattern-a-variable) with a very similar problem but using $read instead of $hfind. Not sure if that's why the method explained there didn't work.

I create a test table (mytable) and populate it with:

hadd mytable user.adam hi
hadd mytable user.bob hi
hadd mytable user.bill hi
hadd mytable user.chad hi

Then I have an ON TEXT to check the table:

on *:TEXT:!test *:#:{
var %i = $hfind($2,$3,0,w)
msg $chan found %i matches
}

And I trigger it with:

!test mytable user.b*

I expect it to find 2 matches but doesn't. I also tried putting $3 into a var and using $hfind($2,%temp,0,w) but nothing there either. And I tried using $+'s, surrounding it with $eval(), using []'s but none of them worked. If "!test mytable user.*" is the input, then "$hfind($2,$3,0,w)" should execute as "$hfind(mytable,user.b*,0,w)", treating the * as a wildcard, right? What am I missing here?!

Re: wildcard hfind with search pattern in string/var [Re: beer] #266212 21/10/19 11:04 AM
Joined: Dec 2002
Posts: 4,584
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,584
If you add an echo for the parameters at the start of the on TEXT event, eg. echo 1: $1 2: $2 3: $3, do you see the expected values?

Re: wildcard hfind with search pattern in string/var [Re: Khaled] #266213 21/10/19 01:25 PM
Joined: Jul 2007
Posts: 53
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 53
Yes:

1: !test 2: mytable 3: user.b*

Re: wildcard hfind with search pattern in string/var [Re: beer] #266214 21/10/19 01:49 PM
Joined: Dec 2002
Posts: 4,584
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,584
If you run the following script, which is your above script but not in an event, what is your result?

Code
test {
  hadd -m mytable user.adam hi
  hadd mytable user.bob hi
  hadd mytable user.bill hi
  hadd mytable user.chad hi
  tokenize 32 !test mytable user.b*
  var %i = $hfind($2,$3,0,w)
  echo found %i matches
}

Re: wildcard hfind with search pattern in string/var [Re: Khaled] #266215 21/10/19 02:32 PM
Joined: Jul 2007
Posts: 53
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 53
I copy&pasted that into remote, prefixed it with "alias" and after doing a "/test", I got:

found 2 matches

Re: wildcard hfind with search pattern in string/var [Re: beer] #266216 21/10/19 03:56 PM
Joined: Jul 2007
Posts: 53
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 53
Ok, I erased and re-typed everything and now it's working as expected. I didn't see any problems originally, is it possible I somehow had a typo that doesn't appear but could cause an issue? Something like a shifted-space or some other key combo that is valid but wouldn't be obvious?