mIRC Homepage
Posted By: oneline sorting script - 04/04/06 10:28 AM
Hi, I need to make a script to sort up to 2500 items that are each up to 4 characters apiece. Each item is a number between 1 and 2,500. I can create a long enough variable with binary variables but I cant pass that variable onto $sorttok() because I get the error:
* String too long: $bvar
if I try to do
Code:
//bset -t &a 1 $str(a,930) | bset -t &b 1 $str(b,930) | bset -t &c 1 $sorttok($bvar(&a,1,9999).text $bvar(&b,1,9999).text,1) | echo -a size: $bvar(&d,0)

size: 930
and I believe if that worked correctly it should have said 1860 since all it did was combine the two variables since the character $chr(1) wasnt in the text. So I assume they will have to be sorted using a script, instead of $sorttok, and I can think of a few simple while loops i could use to sort the full list but they would be very cpu intensive. Im trying to find a lighter way to sort the list as quickly as $sorttok() would with the lightest possible cpu usage. Any help would be greatly appreciated, Thanks.
Posted By: NaquadaServ Re: sorting script - 04/04/06 02:51 PM
Quote:
I need to make a script to sort up to 2500 items that are each up to 4 characters apiece

Not sure in what "form" you want your output data (besides sorted)... You could sort with hash tables and the problem of "set line too long", size hash tables are practically unlimited in number of entries...
Code:
alias hashtest {
  hsetup
  hashout
}
alias hsetup {
  var %n 1
  while (%n <= 2500) {
    hadd -mb hSort %n $+($rand(A,Z), $rand(A,Z), $rand(A,Z), $rand(A,Z))
    inc %n
  }
}
alias hashout {
  var %n 1
  while (%n <= 2500) {
    echo -s $hget(hSort, %n)
    inc %n
  }
}
Posted By: Mpdreamz Re: sorting script - 04/04/06 04:57 PM
using a combination of :
  • /window
  • /loadbuf
  • /filter
  • /savebuf || $line(@window,N)

is in 99% of the cases the best method to sort large quantities fast and clean in mIRC.

You need to be alitle bit more descriptive in what you want to achieve in order to get a better help reply. Though with the above commands (and the order they are in wink ) you already might be able to do what you want.

Good luck!
Posted By: oneline Re: sorting script - 05/04/06 01:36 AM
Quote:
Quote:
I need to make a script to sort up to 2500 items that are each up to 4 characters apiece

Not sure in what "form" you want your output data (besides sorted)... You could sort with hash tables and the problem of "set line too long", size hash tables are practically unlimited in number of entries...
Code:
alias hashtest {
  hsetup
  hashout
}
alias hsetup {
  var %n 1
  while (%n <= 2500) {
    hadd -mb hSort %n $+($rand(A,Z), $rand(A,Z), $rand(A,Z), $rand(A,Z))
    inc %n
  }
}
alias hashout {
  var %n 1
  while (%n <= 2500) {
    echo -s $hget(hSort, %n)
    inc %n
  }
}
Thanks for the reply. Yes but this script would simply return every item in the db and in correct order since the item numbers were done consecutively. In my script each item was added consecutively and is storing data. when i do a $hfind().data on my hash table the values it returns arent sorted in any way because apparently hash tables dont sort. If my script matches more than around 250 items i cant string them along like item1;item2;item3 and pass them to $sorttok because the line is too long.
Posted By: oneline Re: sorting script - 05/04/06 01:38 AM
Quote:
using a combination of :
  • /window
  • /loadbuf
  • /filter
  • /savebuf || $line(@window,N)

is in 99% of the cases the best method to sort large quantities fast and clean in mIRC.

You need to be alitle bit more descriptive in what you want to achieve in order to get a better help reply. Though with the above commands (and the order they are in wink ) you already might be able to do what you want.

Good luck!
Hi, thanks for replying. Sounds like it should do exactly what I want, never thought of doing it that way.
Posted By: PhyxiuS Re: sorting script - 05/04/06 10:39 AM
shocked
© mIRC Discussion Forums