mIRC Home    About    Download    Register    News    Help

Print Thread
#203306 11/08/08 04:58 PM
Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello,

How do I go about deleting all items out of a hash table?

Thanks in advance,

Cheers,

-J

Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Read the help file:
Code:
/help /hfree
/help /hdel

Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Thanks for the reply,

I dont persay want to delete the entire table, rather just remove whatever items are in there.

Code:
alias test1 { echo -a $hget(badword,0).item }
alias test2 {
  var %x = $hget(badword,0).item
  while (%x >= 1) { hdel badword $hget(badword,%x).item | dec %x }
  hsave badword $+($scriptdir,badword.hsh) 
}

This seems to work for now.

Thanks

J
 

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Originally Posted By: help file
/hdel -sw <name> <item>

Deletes an item from a hash table.

The -w switch indicates that item is a wildcard, all matching items are freed.
That means /hdel -w badword * will do what you want.

In your case however, it would probably be faster if you just /hfree'ed the table, then recreated it:
Code:
if ($hget(badword)) hfree badword
hmake badword
hsave badword badword.hsh

or
Code:
hfree -w badword
hmake badword
hsave badword badword.hsh


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Wow!

Works great and less things to do.

Awesome, thanks very much Qwerty

Cheers,

-J



Link Copied to Clipboard