mIRC Home    About    Download    Register    News    Help

Print Thread
Hash Table Question #206662 20/11/08 04:36 AM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
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

Re: Hash Table Question [Re: Buggs2008] #206663 20/11/08 05:10 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Re: Hash Table Question [Re: Buggs2008] #206664 20/11/08 05:13 AM
Joined: Sep 2008
Posts: 62
_
_Memo Offline
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
I am the Key Master, are you the Gate Keeper?

Re: Hash Table Question [Re: Buggs2008] #206674 20/11/08 03:41 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello Genious,

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

Number of matches: 0
Data from match:

Cheers,

Jay

Re: Hash Table Question [Re: Buggs2008] #206687 20/11/08 10:59 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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)
}

Re: Hash Table Question [Re: Buggs2008] #206690 20/11/08 11:34 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
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