mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2004
Posts: 3
L
Longie Offline OP
Self-satisified door
OP Offline
Self-satisified door
L
Joined: Dec 2004
Posts: 3
Hi,

I'm not sure if I should put this here or the bug section, but I'll put it here anyway.

I'm basically filtering snotices and such and going '/hadd -m inc_var nickname text here'. inc_var starts out as 1 but increases each time before the /hadd is called. The reason for this is I want to recall the hash list in the order of each thing happening, but when I make a simple script to list each element in the hash table, I find that it is stored in a weird order.

For example, /viewhash name shouls look like this ->
1 nickname hi there
2 nickname how are you
3 nickname not too bad

but I'm getting
3 nickname not too bad
1 nickname hi there
2 nickname how are you

Those are just made up values, but you get the idea. Do hash tables store in according to the size of the data or is this just odd? I'm using mIRC 6.16 if that helps. This is a quick re-write of the script ...

Code:

alias viewhash {
    var %i 1

    echo -at Listing hashtable entries for $$1
    ;to get the right order
    while($hget($$1, %i) {
        echo -at [H] $hget($$1, %i).item $hget(%i) $hget($$1, %i).data
        inc %i
    }
    echo -at End Of List
}

on *:SNOTICE:*: {
    if ($2 == GLOBAL) {
       var %nick = $left($6, -1)
       ;just for those that like $eval ;)
       ;from memory, you can just use /inc, but I like to be safe
       if (%total_  [ $+ [ %nick ] ]) { inc %total_ [ $+ [ %nick } ] }
       else { %total_ [ $+ [ %nick ] ] = 1 }

        hadd -m %nick %total_ [ $+ [ %nick ] ] $6-
    }
}

 


Any help to clear this up would be great.

Thanks in advance,

Daniel


use &#91code&#93 &#91/code&#93 tags
https://forums.mirc.com/faq.php#html
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
By design, hash table items are stored in random order.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Dec 2004
Posts: 3
L
Longie Offline OP
Self-satisified door
OP Offline
Self-satisified door
L
Joined: Dec 2004
Posts: 3
Ah, ok. Thanks for that.
I was hoping I didn't haev to loop through the table 1,000 times to get teh data in the right order, I want to avoid text files until I need to store the data, maybe I'll write a dll


use &#91code&#93 &#91/code&#93 tags
https://forums.mirc.com/faq.php#html
Joined: Dec 2004
Posts: 14
D
Pikka bird
Offline
Pikka bird
D
Joined: Dec 2004
Posts: 14
but when we allready are at the theme of hashtables weirdnes, is it just here at my mirc or general that the items looses there "" quotes when /hload'ing ? - i had to add an additional line after the /hload to make it append the quotes again (i used them around some filenames that i store in a hashtable)..... confused


- dJabba
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
You could use something like this to sort the items for display.
Code:
alias viewhash {
  echo -at Listing hashtable entries for $$1
  var %w = $+(@,$1,@),%i = 1
  window -hsl %w
  while $hget($1,%i).item { aline %w [H] $v1 $1 $hget($1,%i).data | inc %i }
  %i = 1
  while $line(%w,%i) { echo -a $v1 | inc %i }
  window -c %w
  echo -at End Of List
}


Link Copied to Clipboard