|
Joined: Sep 2006
Posts: 59
Babel fish
|
OP
Babel fish
Joined: Sep 2006
Posts: 59 |
Hi,
When i am using Hash tables or Vars to store data then sort them i keep getting either:
/hadd: line too long or /set: line too long
Is there anyway around this? I am getting these messages due to the amount of data but have no idea how to make a work-around.
|
|
|
|
Joined: Oct 2003
Posts: 313
Fjord artisan
|
Fjord artisan
Joined: Oct 2003
Posts: 313 |
mIRC has a built-in limit of around 950 chars for the length of a "string".
There are a couple of answers to the issue, but all require a rework of how you do your sort - i.e. you cannot use $sorttok() (which is what I assume you're using)
Binvars store data in binary format, and are limited only by the size of your memory. Hash tables used as a list (i.e. each element holds one of the tokens that you would put in your string)
Each of these methods obviously requires you to write your own sort routine.
Sais
|
|
|
|
Joined: Sep 2006
Posts: 59
Babel fish
|
OP
Babel fish
Joined: Sep 2006
Posts: 59 |
I have never used binvars etc, Could you show an example? And yes i am using $sorttok.
|
|
|
|
Joined: Dec 2004
Posts: 66
Babel fish
|
Babel fish
Joined: Dec 2004
Posts: 66 |
There are several ways to sort, depending on your needs and coding preferences, I often like to use a hidden window: /help custom windows The lines can be longer than can actually be displayed, I for get if the limit is mirc’s string length of about 950 characters or less but if you’ve been using tokkens to sort then the window line should be long enough. /SortDemo {
; The h switch hides the window from the user, s for sort
window -hs @SortWin
; Add unsorted lines to window:
aline @SortWin Betty
aline @SortWin Zippy
aline @SortWin Nancy
aline @SortWin Alice
aline @SortWin Quark
aline @SortWin Chirp
; How to display the sorted list to another window:
window -s @Display
aline @Display The sorted list of words:
filter -ww @SortWin @Display *
; How to save the list to a file:
savebuf @SortWin SortedWords.txt
; for testing look at the hidden window:
window -a @SortWin
; close window unless it's a display window:
; window -c @SortWin
}
|
|
|
|
Joined: Sep 2006
Posts: 59
Babel fish
|
OP
Babel fish
Joined: Sep 2006
Posts: 59 |
let me post the code hold on let me get it
|
|
|
|
Joined: Sep 2006
Posts: 59
Babel fish
|
OP
Babel fish
Joined: Sep 2006
Posts: 59 |
So how could i prevent this from giving the line too long error?:
alias sort { var %n = 1, %l = 1 while (%n <= $hget(0)) { var %list = %list $hfind($hget(%n),*,0,w) $+ $hget(%n) $+ $chr(32) inc %n } var %list = $sorttok(%list,32,nr) while (%l <= $numtok(%list,32)) { echo -a $right($gettok(%list,%l,32),-1) inc %l } }
|
|
|
|
Joined: Apr 2004
Posts: 759
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 759 |
quoting from my post on the mIRC.net forums: You could go as far as 938 //hadd -m t t $str(a,938) | echo -a $len($hget(t,1).data) The mirc line limit is 950 characters //echo -a $calc(950 -$len(hadd -m t t))= 939 however theres a space between the last 't' and the data. Note that the editbox allows for 2 more characters // however if you do $str(a,952)<tab> It wont work because line doesn't start with // highest you can go is: $str(a,949)<tab> since the tab is a character as well. If ~900 characters is not enough for you use binary hash item entries. //var %x = $str(a,800) , %y = 1 | bset -t &t 1 %x | bset -t &t 800 %x | bset -t &t 1600 %x | hadd -mb t t &t | noop $hget(t,t,&test) | echo -a $bvar(&test,0) now one hash table entry holds 2399 characters
$maybe
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
and if 2399 characters isn't enough...then I'd have to wonder what you're trying to store.
|
|
|
|
Joined: Feb 2006
Posts: 546
Fjord artisan
|
Fjord artisan
Joined: Feb 2006
Posts: 546 |
the 2399 was just an example i'm sure, the size of the hash table entry containing a binary variable is limited only by your ram in the way things like 'regular' binary variables and other such storage is so if hundreds of megabytes of space isnt enough, then i too wonder what youre trying to store!
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
|
|
|
|
Joined: Dec 2004
Posts: 66
Babel fish
|
Babel fish
Joined: Dec 2004
Posts: 66 |
I see from your $sorttok(%list,32,nr) that you are doing a reverse numeric sort, /window only does a plain alpha sort, but it’s easy to script the other two. To reverse it just read the window from the bottom up, SortInWindow does that. But for a numeric sort if the number of digits varies you need to left pad the number with zeros to the length of the largest number that the script might handle. It would help to see several examples of the data you are handling in the hash and sort. alias SortInWindow {
window -hs @SortWin
var %n = $hget(0)
while (%n) {
aline @SortWin $hfind($hget(%n),*,0,w) $+ $hget(%n)
dec %n
}
var %l = $line(@SortWin,0)
while (%l) {
echo -a $right($line(@SortWin,%l),-1)
dec %l
}
window -c @SortWin
}
alias LeftPadNum {
; Call: $LeftPadNum(Number2BePadded, WidthAfterPadding)
return $str(0,$calc($2 - $len($1))) $+ $1
}
alias test.LeftPadNum {
; In this example the number is padded to 5 didgets wide, 654321 shows
; that a longer number will simply be returned
echo -a $LeftPadNum(2,5)
echo -a $LeftPadNum(47,5)
echo -a $LeftPadNum(2947,5)
echo -a $LeftPadNum(41879,5)
echo -a $LeftPadNum(654321,5)
}
|
|
|
|
Joined: Feb 2006
Posts: 546
Fjord artisan
|
Fjord artisan
Joined: Feb 2006
Posts: 546 |
you could also use $base(N,10,10,M) to pad an integer to size M, eg. $base(2,10,10,5) = 00002
and even sort the window numerically with /filter, /filter -teuwwc 1 32 @sortwin @sortwin which doesn't require any number padding :P
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
|
|
|
|
Joined: Dec 2004
Posts: 66
Babel fish
|
Babel fish
Joined: Dec 2004
Posts: 66 |
Cool jaytea, I haven’t used $base before, have seen it in Help but didn’t catch that it could pad numbers. I use /filter a lot, but haven’t used several of those options. Thanks
|
|
|
|
|