mIRC Home    About    Download    Register    News    Help

Print Thread
#109299 27/01/05 01:12 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
what's the best way too.. rename the items in a hash table...

example

item data
global.text.1.kick #help
global.text.2.kickban #ms
global.text.3.op #bla
global.text.4.voice #[censored]
global.text.5.time #damn
global.text.6.test #hi


if i wanted to rename every item starting from global.text.2.kick till global.text.6.test

basically delete global.text.2.kick 1st, then rename the rest.

any ideas?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
alias blah1234 {
  ; $1 = number to make number 1 ( no bounds checks occur add them if u want )
  ;
  var %i = $1 | dec %i
  while (%i) {
    hdel -s hashtablename $hfind(hashtablename,global.text. $+ %i $+ .*,1,w)
    dec %i
  }
  var %i = $1
  while ($hfind(hashtablename,global.text. $+ %i $+ .*,1,w)) {
    var -s %old.item = $ifmatch
    var -s %old.item.value = $hget(hashtablename,%old.item)
    hadd -s hashtablename $puttok(%old.item, $calc(%i - $1 + 1) , 3,46) %old.item.value
    hdel -s hashtablename %old.item
    inc %i
  }
}


The above makes some assumptions about the hash table, that it only ever contains one item that starts with global.text.N. (N being a number), ie inly one global.text.1.* , only one global.text.2.* etc

Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
think i didn't explain it very well.

Quote:
what's the best way too.. rename the items in a hash table...

example

item data
global.text.1.kick #help
global.text.2.kickban #ms
global.text.3.op #bla
global.text.4.voice #[censored]
global.text.5.time #damn
global.text.6.test #hi


if i wanted to rename every item starting from global.text.2.kick till global.text.6.test
basically delete global.text.2.kick 1st, then rename the rest while keeping the same data.

item data
global.text.1.kick #help
global.text.2.op #bla
global.text.3.voice #[censored]
global.text.4.time #damn
global.text.5.test #hi


any ideas?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
alias blah1234 {
  ; $1 = number to delete, all higher numbers move down one
  ;
  if ($hfind(hashtablename,global.text. $+ $1 $+ .*,1,w)) {
    hdel hashtablename $ifmatch
    var %i = $1 | inc %i
    while ($hfind(hashtablename,global.text. $+ %i $+ .*,1,w)) {
      var -s %old.item = $ifmatch
      var -s %old.item.value = $hget(hashtablename,%old.item)
      hadd -s hashtablename $puttok(%old.item, $calc(%i - 1) , 3,46) %old.item.value
      hdel -s hashtablename %old.item
      inc %i
    }
  }
}


Assuptions I have made are, that there is only ever one item named global.text.N.* (N being a number), and that the numbering well not have gaps.


Link Copied to Clipboard