mIRC Home    About    Download    Register    News    Help

Print Thread
#206662 20/11/08 04:36 AM
B
Buggs2008
Buggs2008
B
Hello,


I have the following in a hash table named [info]

Hash Table Name: info
Item: Buggs2008
Data: 5f67d56b2beb4a8b8ff3433eea054532,2008/11/19 @ 11:20 pm

Let's say I am looking for his gatekeeper, "5f67d56b2beb4a8b8ff3433eea054532" , how can I search the hash table based on on that and either get it to return a 1 or $true for found.

Here's what I have so far but its not working.

Code:
test {

  ;5f67d56b2beb4a8b8ff3433eea054532

  var %search = 5f67d56b2beb4a8b8ff3433eea054532

  echo -a $hfind(info,$+(*,$gettok(%search,2,44),*),0,w)
}



Thanks in advance,

Cheers,

Jay

#206663 20/11/08 05:10 AM
Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
If the data is always in the same format, and assuming there is only ever 1 match for your search criteria, you can use this:

Code:

test {
  var %search = 5f67d56b2beb4a8b8ff3433eea054532,*
  echo -a Number of matches: $hfind(info,%search,w,0).data
  echo -a Data from match: $hget(info,$hfind(info,%search,w,1).data)
}


(untested)

-genius_at_work

#206664 20/11/08 05:13 AM
_
_Memo
_Memo
_
I am the Key Master, are you the Gate Keeper?

#206674 20/11/08 03:41 PM
B
Buggs2008
Buggs2008
B
Hello Genious,

I can't get it to work properly and im out of ideas =\

Number of matches: 0
Data from match:

Cheers,

Jay

#206687 20/11/08 10:59 PM
Joined: Jan 2007
Posts: 1,155
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,155
When I design a hash table I like to make the identifying piece of data that I am most commonly going to be searching for the item name. So you would search for ...

$hget(info,<gatekeeper>)

What are you searching for most often in the hash table? Nickname? Gatekeeper?

To answer your issue, you need to use the .data property when searching the data field. Without it, $hfind is looking for a match in the item's.

Originally Posted By: mIRC help file

$hfind(name/N, text, N, M)

Searches table for the Nth item name which matches text. Returns item name.

Properties: data

If you specify the .data property, searches for a matching data value.


If Genius' code doesn't work it is because you specify the Nth item name BEFORE the w signifying wildcard search.

Try...

Code:
test {
  var %search = 5f67d56b2beb4a8b8ff3433eea054532,*
  echo -a Number of matches: $hfind(info,%search,0,w).data
  echo -a Data from match: $hget(info,$hfind(info,%search,1,w).data)
}

#206690 20/11/08 11:34 PM
B
Buggs2008
Buggs2008
B
Hello DJ_Sol,

I just wanted to say that your code works great and that was exactly what I was looking for.

Thanks again for all the help and support that you guys have provided to me.

Cheers,

Jay


Link Copied to Clipboard