mIRC Home    About    Download    Register    News    Help

Print Thread
Renaming a hash table? #87903 23/06/04 03:46 PM
Joined: Apr 2003
Posts: 25
S
SS217 Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Apr 2003
Posts: 25
Is it possible to just rename a hash table without making a new one and loading the old into the new?

Re: Renaming a hash table? #87904 23/06/04 03:53 PM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Nope, i made something to load it all for you though:

Code:
alias hrename {
 if !$hget($1) { echo -ac Info * /hrename: ' $+ $1 $+ ' no such table. }
 else {
   if $hget($2) { .hfree $2 }
   var %i = 1
   while $hget($1,%i).item {
     hadd -m $2 $ifmatch $hget($1,%i).data
     inc %i
   }
   .hfree $1
 }
}


/hrename table newtable


New username: hixxy
Re: Renaming a hash table? #87905 23/06/04 03:59 PM
Joined: Apr 2003
Posts: 25
S
SS217 Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Apr 2003
Posts: 25
Thanks tidy, but I don't think it can free it fast enough. The problem is I have to delete anywhere from 1-127 lines from a hash table and write new ones items in a very short time period. It's okay but the writing is going faster than the deleting, so as its deleting its writing so only a few items may be in the table.

Last edited by SS217; 23/06/04 04:00 PM.
Re: Renaming a hash table? #87906 23/06/04 06:25 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
You may find it easier (and faster for big tables) to use the following:

alias hrename hmake $$2 | hsave -o $1 tmp | hfree $1 | hload $2 tmp | .remove tmp