mIRC Home    About    Download    Register    News    Help

Print Thread
#146425 04/04/06 10:28 AM
Joined: Apr 2006
Posts: 14
O
oneline Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2006
Posts: 14
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.

#146426 04/04/06 02:51 PM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
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
  }
}


NaquadaBomb
www.mirc-dll.com
#146427 04/04/06 04:57 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
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!


$maybe
#146428 05/04/06 01:36 AM
Joined: Apr 2006
Posts: 14
O
oneline Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2006
Posts: 14
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.

#146429 05/04/06 01:38 AM
Joined: Apr 2006
Posts: 14
O
oneline Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2006
Posts: 14
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.

#146430 05/04/06 10:39 AM
Joined: Oct 2005
Posts: 126
Vogon poet
Offline
Vogon poet
Joined: Oct 2005
Posts: 126
shocked


If you mess with the best, u will die like the rest !

Link Copied to Clipboard