mIRC Home    About    Download    Register    News    Help

Print Thread
#102087 04/11/04 12:39 PM
G
gencha
gencha
G
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,')
} 

S
Sigh
Sigh
S
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

G
gencha
gencha
G
humm didn't even come to my mind. thanks

Joined: Nov 2004
Posts: 822
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 822
Code:
/hcopy {
  hsave $1 tempfile
  hmake $2 $hget($1,*).data
  hload $2 tempfile
  .remove tempfile
}


I'd like to see a /hrename function.


Link Copied to Clipboard