mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2007
Posts: 66
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 66
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?!

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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?

Joined: Jul 2007
Posts: 66
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 66
Yes:

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

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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
}

Joined: Jul 2007
Posts: 66
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 66
I copy&pasted that into remote, prefixed it with "alias" and after doing a "/test", I got:

found 2 matches

Joined: Jul 2007
Posts: 66
B
beer Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2007
Posts: 66
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?


Link Copied to Clipboard