mIRC Homepage
Posted By: SS217 Renaming a hash table? - 23/06/04 03:46 PM
Is it possible to just rename a hash table without making a new one and loading the old into the new?
Posted By: tidy_trax Re: Renaming a hash table? - 23/06/04 03:53 PM
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
Posted By: SS217 Re: Renaming a hash table? - 23/06/04 03:59 PM
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.
Posted By: Online Re: Renaming a hash table? - 23/06/04 06:25 PM
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
© mIRC Discussion Forums