|
Joined: May 2008
Posts: 329
Fjord artisan
|
OP
Fjord artisan
Joined: May 2008
Posts: 329 |
Can someone tell me what is wrong with this: /search3 {
set %hash seen
set %search QUIT
var %a = $hfind(%hash,* $+ %search $+ *,0,w).data
echo -s total: %a
while (%a) {
echo -s %a : $hfind(%hash,* $+ %search $+ *,%a,w).data is $hget(%hash,%a).data
dec %a
}
} It's showing weird results, items that down have *QUIT* in them.
I registered; you should too.
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
/search3 {
var %hash seen ,%search QUIT ,%a = $hfind(%hash,$+(*,%search,*),0,w).data
echo -s total: %a
while (%a) {
var %h $hfind(%hash,$+(*,%search,*),%a,w).data
echo -s %h is $hget(%hash,%h)
dec %a
}
} Edit : It was showing weird result because your code was false, The data of the Nth item is not for sure the data of the N match
Last edited by Wims; 09/06/08 01:05 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: May 2008
Posts: 329
Fjord artisan
|
OP
Fjord artisan
Joined: May 2008
Posts: 329 |
/search3 {
var %hash seen ,%search QUIT ,%a = $hfind(%hash,$+(*,%search,*),0,w).data
echo -s total: %a
while (%a) {
var %h $hfind(%hash,$+(*,%search,*),%a,w).data
echo -s %h is $hget(%hash,%h)
dec %a
}
} Edit : It was showing weird result because your code was false, The data of the Nth item is not for sure the data of the N match Thanks, I'd wondered about that, but I didn't know how to fix it. What about this code to wildcard search item names? It worked the way I had it, but I updated it to correct the wildcard string. Same result. /search {
var %hash = seen ,%search = apple, %a = 1
while ($hfind(%hash,$+(*,%search,*),%a,w)) {
echo -s %a : $hfind(%hash,$+(*,search,*),%a,w) is $hget(%hash,%a).data
inc %a
}
}
I registered; you should too.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
You have to use the data location returned by the $hfind in the $hget to reference the correct item in the hash table. For example your code could be searching for the 3rd item that matches the required data, but the 3rd match might be the 50th entry, so $hget(table,3) <which you're currently using> would be the incorrect entry. Instead try
/search {
var %hash = seen ,%search = apple, %a = 1, %b = $hget(%hash,0).item
while %a <= %b {
%entry = $hfind(%hash,$+(*,%search,*),%a,w)
if %entry {
echo -s %a : %entry is $hget(%hash,%entry).data
}
inc %a
}
}
|
|
|
|
Joined: May 2008
Posts: 329
Fjord artisan
|
OP
Fjord artisan
Joined: May 2008
Posts: 329 |
You have to use the data location returned by the $hfind in the $hget to reference the correct item in the hash table. For example your code could be searching for the 3rd item that matches the required data, but the 3rd match might be the 50th entry, so $hget(table,3) <which you're currently using> would be the incorrect entry. Instead try
/search {
var %hash = seen ,%search = apple, %a = 1, %b = $hget(%hash,0).item
while %a <= %b {
%entry = $hfind(%hash,$+(*,%search,*),%a,w)
if %entry {
echo -s %a : %entry is $hget(%hash,%entry).data
}
inc %a
}
}
echo -s %a : %entry is $hget(%hash,%entry).data should be echo -s %a : %entry is $hget(%hash,%entry) so the data is shown
I registered; you should too.
|
|
|
|
Joined: May 2008
Posts: 329
Fjord artisan
|
OP
Fjord artisan
Joined: May 2008
Posts: 329 |
Thank you for bringing this to my attention. I have adjusted the search modeules and the usermatch module.
I registered; you should too.
|
|
|
|
|