mIRC Homepage
Posted By: gencha /hcopy - Copy hash tables - 04/11/04 12:39 PM
i would like to see a command to copy an entire hash table.
i know it wouldn't benefit a lot of people, and it's easy to write such a script. but still maybe in a future version it could be implemented just for performance reasons.
until then here is the script i use right now to do the job if someone's interested.

Code:
alias hcopy {
  if ($1 == -s) {
    tokenize 32 $2-
    var %s = $true
  }
  if (!$hget($1)) {
    echo -s * /hcopy: no such table $+(',$1,')
    return
  }
  if ($hget($2)) hfree $2
  hmake $2 $hget($1).size
  var %items = $hget($1,0).item, %item = 1, %it
  while (%item <= %items) {
    var %it = $hget($1,%item).item
    hadd $2 %it $hget($1,%it)
    inc %item
  }
  if (%s) echo -s * Hashtable $+(',$1,') copied to $+(',$2,')
} 
Posted By: Sigh Re: /hcopy - Copy hash tables - 04/11/04 01:03 PM
Rather than loop you can use /hsave and /hload for this, /hsave -uob table1 tmpfile followed by /hmake table2 $hget(table1).size and /hload -b table2 tmpfile
Posted By: gencha Re: /hcopy - Copy hash tables - 05/11/04 12:47 PM
humm didn't even come to my mind. thanks
Posted By: Jigsy Re: /hcopy - Copy hash tables - 24/11/04 10:38 AM
Code:
/hcopy {
  hsave $1 tempfile
  hmake $2 $hget($1,*).data
  hload $2 tempfile
  .remove tempfile
}


I'd like to see a /hrename function.
© mIRC Discussion Forums