mIRC Homepage

Hash Table Question

Posted By: Buggs2008

Hash Table Question - 20/11/08 04:36 AM

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
Posted By: genius_at_work

Re: Hash Table Question - 20/11/08 05:10 AM

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
Posted By: _Memo

Re: Hash Table Question - 20/11/08 05:13 AM

I am the Key Master, are you the Gate Keeper?
Posted By: Buggs2008

Re: Hash Table Question - 20/11/08 03:41 PM

Hello Genious,

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

Number of matches: 0
Data from match:

Cheers,

Jay
Posted By: DJ_Sol

Re: Hash Table Question - 20/11/08 10:59 PM

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)
}
Posted By: Buggs2008

Re: Hash Table Question - 20/11/08 11:34 PM

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
© 2021 mIRC Discussion Forums