mIRC Home    About    Download    Register    News    Help

Print Thread
#33823 03/07/03 04:25 PM
Joined: Jan 2003
Posts: 127
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Jan 2003
Posts: 127
I need help on making hash table!
I need to save the nick of a query open, and when the query is close and open again, the nick of the query would be save again! When disconnected, table is purge? Any help grin

#33824 03/07/03 04:38 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
On *:OPEN:?: hadd -m MyTable $nick [data]
On *:CLOSE:?: if ($hget(MyTable)) hdel MyTable $nick [data]
On *:DISCONNECT: if ($hget(MyTable)) hfree MyTable


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#33825 03/07/03 04:41 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
on *:start: {
  if ($hget(nicks) == $null) {
   hmake nicks 60
   if ($exists(nicks.hsh) == $true) { hload nicks nicks.hsh }
}
}

on *:exit: {
if ($hget(nicks) != $null) { hsave -o nicks nicks.hsh }
}
on *:disconnect: {
if ($hget(nicks) != $null) { hsave -o nicks nicks.hsh }
}

on *:OPEN:*:?: { 
hadd -m query_nicks $nick true  
}

I am most probably wrong. I really don't understand the concept of hash tables. grin

#33826 03/07/03 04:44 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Quote:

If Raccoon knows it then I must have been wrong. mad

#33827 03/07/03 04:48 PM
Joined: Jan 2003
Posts: 127
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Jan 2003
Posts: 127
So is your suggestion wrong? confused How do we check if the saved_nick in the hash table exist?

Last edited by littlecramp; 03/07/03 04:49 PM.
#33828 03/07/03 04:55 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
$hget(MyTable,$nick) will return [data] if it exists.
If the nicks don't need any data associated with them, then just use '1' as data or something, but it must be filled to use $hget effeciently.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#33829 03/07/03 05:01 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
This is a long shot but would this work?
Code:
on *:OPEN:*:?: {
  if ($nick == $hget(nicks,$nick)) {
  hadd -m nicks $nick true
 }
}

confused

#33830 03/07/03 05:38 PM
Joined: Jan 2003
Posts: 127
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Jan 2003
Posts: 127
"hsave -o nicks nicks.hsh". Can I say that a file(save using hsave) can contain mutiple table? It is a must to load table in order to retrieve the table or item value?

Sorry to ask so much, but I dont know how to use hash table, been using /write /writeini $read $readini $ini all the while!

#33831 03/07/03 05:49 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
* Raccoon wonders if his answers didn't answer your questions, or if there is something he left out.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#33832 04/07/03 10:16 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Handy (for me at least) shortcut: instead of if $hget(name) { hfree name } you could use hfree -w name


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#33833 05/07/03 03:05 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
ooh, nifty keen.
damn j00 hax0r


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard