mIRC Home    About    Download    Register    News    Help

Print Thread
/hcopy - Copy hash tables #102087 04/11/04 12:39 PM
Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
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,')
} 

Re: /hcopy - Copy hash tables #102088 04/11/04 01:03 PM
Joined: Aug 2003
Posts: 314
S
Sigh Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
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

Re: /hcopy - Copy hash tables #102089 05/11/04 12:47 PM
Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
humm didn't even come to my mind. thanks

Re: /hcopy - Copy hash tables #102090 24/11/04 10:38 AM
Joined: Nov 2004
Posts: 804
Jigsy Offline
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 804
Code:
/hcopy {
  hsave $1 tempfile
  hmake $2 $hget($1,*).data
  hload $2 tempfile
  .remove tempfile
}


I'd like to see a /hrename function.


What do you do at the end of the world? Are you busy? Will you save us?