mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Code:
alias sort {
filter -a @values @sorted sort1
}

alias sort1 {
  if ($1 < $2) return 1
  elseif ($1 > $2) return -1
  else return 0
}


^ Example of what I am doing. The problem is, it is sorting 7.78 above 10.2, etc.

Example:

7.78
5.56
4.43
2.34
10.5
1.02

It is like it has no regard to decimal place. How do I fix this without changing 7.78 to 07.78, etc.

Thanks!

Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Just tried:

/filter -tu 6 9 @values @sorted

I got the same results as before.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Use
Code:
filter -wwteu 1 32 @value @sorted


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
I am still getting the same results using -wwteu

-wwteu = window in, window out, sort, descending, numeric sort

Still same results.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Code:
//window @sorted | window @values | tokenize 32 7.78 5.56 4.43 2.34 10.5 1.02 | aline @values $* | filter -wwteu 1 32 @values @sorted
This should work.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Wow, yes that works, but how I am doing it it is not working.

Code:
filter -wwteu 6 9 @UK_values @UK_temp


The windows are opened normally: /window @UK_values, etc.

Ex. of what is in that window:

Quote:
Achilles Priest (120:129) 31581 36721 5140 16.275609


^ All seperated by $chr(9) 'Tabs'

Why is it tabbed? Because the actual window it will end up in has tabbing for organization of the information, as well as other summaries of the data that would jack up the /filter so I put it in a hidden window @UK_values that way i can jsut sort that, then reload the values to be displayed.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Hum ok, I've noticed that numbers with decimal value in your example are the 7th token (space separated), not the 6th, could it be the problem ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
'Priest (120:129)' is in one column, so the 6th column is correct for sorting that particular column, however, this happens with the other colums as well:

Example:

910
90346
89992345
88567
567
5578
etc.

The data is aline'd normally in a -l -t10,etc. window seperated by $chr(9) for tabbing. I don't get it.

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Could you perhaps paste your entire script? Whatever I do I can't recreate your behaviour. Also, what mIRC version are you using?

Code:
//echo -a $version $os $md5($mircexe,2) $dll(0) $script(0) $com(0)

What does this code return?

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Try to not use -t for /window because /filter use $chr(9) to know which column he has to check,


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Originally Posted By: Wims
Try to not use -t for /window because /filter use $chr(9) to know which column he has to check,

Even if I use his -t10 switch, I still get a normal sort.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Ok, I couldn't test this myself smile



#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Originally Posted By: 5618
Could you perhaps paste your entire script? Whatever I do I can't recreate your behaviour. Also, what mIRC version are you using?

Code:
//echo -a $version $os $md5($mircexe,2) $dll(0) $script(0) $com(0)

What does this code return?


Returns: 6.35 XP 2f63a83968f9586fe4fb48134253619c 0 18 0

Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
I was going to clean this up before I showed it to anyone but I am in a time crunch and my wife is bickering at me to go somewhere with her so I wanted to post so hopefully will have a response when I get home. Be gentle. >.<

Code:
; UK Tool

alias ukt {
  if (!$dialog(uk.tool)) dialog -md uk.tool uk.tool
  else dialog -v uk.tool uk.tool
}

dialog uk.tool {
  title "UK Tool v1.01"
  size -1 -1 153 84
  option dbu

  tab "Format", 5, -2 -15 193 128
  edit "", 29, 1 12 151 72, tab 5 multi return autohs autovs vsbar
  combo 32, 2 0 149 50, tab 5 sort size drop

  tab "Progress", 15
  list 1, 1 1 75 50, tab 15 size
  list 2, 77 1 75 50, tab 15 size
  button "Compare", 3, 114 53 37 12, tab 15 flat

  menu "File", 17
  menu "Tools", 33, 17
  item "Formatter", 34, 33
  item "Comparator", 35, 33
  item break, 90, 17
  item "Format and Save", 36, 17
  item "Load Selected", 37, 17
  item break, 91, 17
  item "Paste Data", 38, 17
  item "Clear Data", 39, 17
  item break, 92, 17
  item "Exit", 40, 17, cancel

  menu "Help", 18
  item "View Help", 25, 18
  item "About..", 26, 18
}

on 1:dialog:uk.tool:init:0:{
  did -ra $dname 29 Paste data here!
  uk.filecombo
}

on 1:dialog:uk.tool:menu:*:{
  echo -a MENU ID: $did
  if ($did == 34) {
    did -f $dname 5
    did -e $dname 36,37,38,39
  }
  elseif ($did == 35) { 
    did -f $dname 15
    did -b $dname 36,37,38,39
  }
  elseif ($did == 36) uk.format
  elseif ($did == 37) {
    if ($did(32).seltext != New File..) {
      var %f $+($scriptdir,$did(32).seltext)
      did -r $dname 29
      loadbuf $calc($lines(%f) -1) -o uk.tool 29 $shortfn(%f)
    }
  }
  elseif ($did == 38) {
    did -r $dname 29
    uk.paste
  }
  elseif ($did == 39) did -r $dname 29

  elseif ($did == 18) {
    ;help file
  }
  elseif ($did == 26) {
    echo 4 -ta UK Tool v1.01 by napalm [17/MAY/2009]
  }
}

on *:dialog:uk.tool:sclick:*:{
  echo -a CLICK: $did
  if ($did == 32) {
    if ($did(32).seltext == New File..) did -n $dname 29
    else did -m $dname 29
  }
  elseif ($did == 3) { if ($window(@UK_Tool)) clear @UK_Tool | uk.compare }
}

on 1:close:@UK_Tool:{ 
  close -@ @UK*
  unset %UK_win_*
}

;======== aliases =========

alias uk.paste {
  var %x 1
  while ($cb(%x)) {
    did -a uk.tool 29 $ifmatch $+ $crlf
    inc %x
  }
}

alias ukf return $+(",$scriptdir,UKT_,$$1,GMT.txt")

alias -l uk.format {
  var %time $gmt , %f $ukf($asctime(%time,ddmmmyy_HH-nn-ss_))
  window -h @uk.temp
  filter -ik uk.tool 29 uk.fmt2
  did -r uk.tool 29
  filter -wo @uk.temp uk.tool 29
  write %f %time
  filter -if uk.tool 29 %f
  close -@ @uk.temp
  uk.filecombo
}
alias -l uk.fmt2 {
  tokenize 9 $1
  echo @uk.temp $1 $+ $chr(9) $+ $remove($deltok($2,2,32),$chr(44))
}

alias uk.filecombo {
  did -r uk.tool 1,2,32
  var %x 1
  did -a uk.tool 32 New File..
  while ($findfile($scriptdir,UKT_*.txt,%x)) {
    did -a uk.tool 1,2,32 $nopath($ifmatch)
    inc %x
  }
}

alias ukc.buffer {
  clear @UK_Tool
  aline $color(background) @UK_Tool $1 $2

  aline @UK_Tool From: $asctime($1,dd mmm yy - HH:nn:ss) $chr(9) $chr(9) $chr(9) 4RED = No Change
  aline @UK_Tool To: $asctime($2,dd mmm yy - HH:nn:ss) $chr(9) $chr(9) $chr(9) 2BLUE = New User
  aline @UK_Tool Span: $duration($calc($2 - $1))

  aline @UK_Tool $chr(160)
  aline @UK_Tool Rank $chr(9) User $chr(9) Old Exp $chr(9) New Exp $chr(9) Exp Gained $chr(9)  $+ $chr(37) $+ Change
  aline @UK_Tool $chr(160)
}

alias ukc.hilight {
  if (!$1) return 02
  elseif (!$2) return 04
}  

alias uk.compare {
  var %f1 $shortfn($+($scriptdir,$did(1).seltext)) , %f2 $shortfn($+($scriptdir,$did(2).seltext)) 
  var %fnew , %fold , %x 1 , %nexp 0 , %oexp 0 , %dexp 0 , %prexp 0 , %n , %r , %h

  if (!$window(@UK_Tool)) { 
    window -lk0 -t12,42,52,62,77 @UK_Tool "Courier New" 14
    titlebar @UK_Tool - Data Comparison
  }
  if (!$window(@UK_values)) window -lh @UK_values
  else clear @UK_values

  if ($read(%f1,1) > $read(%f2,1)) { %fnew = %f2 | %fold = %f1 }
  else { %fnew = %f2 | %fold = %f1 }

  echo -s $asctime(%f1,yymmdd) $asctime(%f1,yymmdd)

  ukc.buffer $read(%fold,0) $read(%fnew,0)

  while ($read(%fnew,%x)) {
    tokenize 9 $ifmatch
    %n = $gettok($gettok($1,1,40),-1,32)
    %r = $iif($numtok($1,32) >= 3,$gettok($1,-3-1,32))
    %nexp = $2
    %oexp = $gettok($read(%fold,r,$+(\s,%n,\s)),2,9)
    %dexp = $calc(%nexp - %oexp)
    %prexp = $calc((%dexp / %oexp) * 100)
    %h = $ukc.hilight(%oexp,%prexp)
    aline %h @UK_Tool %r $chr(9) $gettok($1,-2--1,32) $chr(9) %oexp $chr(9) %nexp $chr(9) $iif(%oexp,%dexp,0) $chr(9) $iif($len($int(%prexp)) == 1,0) $+ %prexp
    aline %h @UK_values %r $chr(9) $gettok($1,-2--1,32) $chr(9) %oexp $chr(9) %nexp $chr(9) $iif(%oexp,%dexp,0) $chr(9) $iif($len($int(%prexp)) == 1,0) $+ %prexp
    inc %x
  }
  set %UK_win_sort -ne
  set %UK_win_sort_t 0
}

alias uk.sort {
  var %m 0 , %i , %t %UK_win_sort

  if ($findtok(-ra -us -oe -ne -ge -pr,%t,1,32)) { 
    %i = $v1 | %m = -tz $+ $iif(%i > 2,ue) %i 9
  }
  else return

  ukc.buffer $line(@UK_Tool,1)

  filter %m @UK_values @UK_Tool
}

;====== Popups ======

menu @UK_Tool {
  Sort by..
  .$iif(%UK_win_sort == -pr,$style(1)) $+($chr(37),Change):set %UK_win_sort -pr | uk.sort
  .-
  .$iif(%UK_win_sort == -oe,$style(1)) Old Exp:set %UK_win_sort -oe | uk.sort
  .$iif(%UK_win_sort == -ne,$style(1)) New Exp:set %UK_win_sort -ne | uk.sort
  .$iif(%UK_win_sort == -ge,$style(1)) Gained Exp:set %UK_win_sort -ge | uk.sort
  .-
  .$iif(%UK_win_sort == -ra,$style(1)) Rank:set %UK_win_sort -ra | uk.sort
  .$iif(%UK_win_sort == -us,$style(1)) User:set %UK_win_sort -us | uk.sort
}


menu channel,status,menubar {
  -
  UK Tool:ukt
}

Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Example of one of the .txt files it formats/analyzes:

Quote:

1242558215
Nemesis taian (110:80) 826692
Zeus reas0nabledoubts (46:45) 728188
Atlas Firewall (67:100) 708911
Atlas ziming (183:57) 701795
Atlas oley (80:60) 671597
Asclepius Arman (177:74) 663031
Atlas Obama (109:13) 657537
Atlas xajdyk (77:43) 638589
Atlas xxxJKxxx (43:21) 581583
Achilles Wulfgar (23:83) 579112
Atlas jessus23 (65:105) 572166


ok really gotta go, bbl

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Ok, I can't fully analyze your code since I don't know what values some variables have. However, it's become clear to me your are not correct in sorting the 6th column separated by char 9. Sorting the wrong column will result in what you see happening. This points to a bug in secondary sorting though, in my opinion.
See what happens when you sort on "5 9" or "7 9". The first one is more likely.

P.S. In your last example of text format, you would of course expect the filter sort to be done for "3 9" and not "6 9" since there are only 3 columns there (unfortunately -1 is not supported as an Nth column value).

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
I just noticed that as one of the temporary steps, the data seems to be tokenized by char 9 and then filtered. This effectively causes tab chars to be lost in the custom window. This would result in the line...

Achilles Priest (120:129) 31581 36721 5140 1.02

... to only contain spaces inbetween and sorting of the last value to simply become...
Code:
/filter -wwtue 7 32 @value @sorted

Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Originally Posted By: 5618
Ok, I can't fully analyze your code since I don't know what values some variables have. However, it's become clear to me your are not correct in sorting the 6th column separated by char 9. Sorting the wrong column will result in what you see happening. This points to a bug in secondary sorting though, in my opinion.
See what happens when you sort on "5 9" or "7 9". The first one is more likely.

P.S. In your last example of text format, you would of course expect the filter sort to be done for "3 9" and not "6 9" since there are only 3 columns there (unfortunately -1 is not supported as an Nth column value).


There is a popup for that window that sorts different colums, and regardless of the column sorted, it is still sorted, but incorrectly. Also, the only /tokenize 9 i did is when formatting the .txt file (which is the 'last example of text format) because it is two values seperated by $chr(9) example:

Achillies UserName (1:1) $chr(9) 1000000

So I tokenize it when reading it in to be formatted easier. The output of that routine is what is put into the windows seperated by $chr(9) for tabbing.

Also, the /filter does not 'lose' the $chr(9) and output as spaces, if it did, it would be highly noticeable.

Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
Paste this code into an empty file and type /jack

The aliases txt.jack and txt.old.jack are emulating what the actual text files would return. (Except old jack he's just returning the old exp values).

Right click in the @Window and sort the different columns. Edit the exp vaules in the txt.jack aliases if you need clearer examples.

Code:
alias jack {
  if (!$window(@UK_Tool)) { 
    window -lk0 -t12,42,52,62,77 @UK_Tool "Courier New" 14
    titlebar @UK_Tool - Data Comparison
  }
  if (!$window(@UK_values)) window -lh @UK_values
  else clear @UK_values
  buffer.jack  
  var %x 1 , %nexp 0 , %oexp 0 , %dexp 0 , %prexp 0 , %n , %r
  while ($txt.jack(%x)) {
    tokenize 9 $ifmatch
    %n = $gettok($gettok($1,1,40),-1,32)
    %r = $1
    %nexp = $2
    %oexp = $txt.old.jack(%x)
    %dexp = $calc(%nexp - %oexp)
    %prexp = $calc((%dexp / %oexp) * 100)
    aline @UK_Tool %r $chr(9) %n $chr(9) %oexp $chr(9) %nexp $chr(9) $iif(%oexp,%dexp,0) $chr(9) %prexp
    aline @UK_values %r $chr(9) %n $chr(9) %oexp $chr(9) %nexp $chr(9) $iif(%oexp,%dexp,0) $chr(9) %prexp
    inc %x
  }
  set %UK_win_sort -ne
}

alias txt.jack {
  if ($1 == 1) return Nemesis taian (110:80) $chr(9) 886692
  elseif ($1 == 2) return Zeus reas0nabledoubts (46:45) $chr(9) 928188
  elseif ($1 == 3) return Atlas Firewall (67:100) $chr(9) 709911
  elseif ($1 == 4) return Atlas ziming (183:57) $chr(9) 705795
  elseif ($1 == 5) return Atlas oley (80:60) $chr(9) 711597
  else return
}

alias txt.old.jack {
  if ($1 == 1) return 826692
  elseif ($1 == 2) return 728188
  elseif ($1 == 3) return 708911
  elseif ($1 == 4) return 701795
  elseif ($1 == 5) return 671597
  else return
}

alias buffer.jack {
  clear @UK_tool
  aline @UK_Tool $chr(160)
  aline @UK_Tool Rank $chr(9) User $chr(9) Old Exp $chr(9) New Exp $chr(9) Exp Gained $chr(9)  $+ $chr(37) $+ Change
  aline @UK_Tool $chr(160)
}

alias sort.jack {
  var %m 0 , %i , %t %UK_win_sort
  if ($findtok(-ra -us -oe -ne -ge -pr,%t,1,32)) { 
    %i = $v1 | %m = -tz $+ $iif(%i > 2,ue) %i 9
  }
  else return
  buffer.jack
  filter %m @UK_values @UK_Tool
}

menu @UK_Tool {
  Sort by..
  .$iif(%UK_win_sort == -pr,$style(1)) $+($chr(37),Change):set %UK_win_sort -pr | sort.jack
  .-
  .$iif(%UK_win_sort == -oe,$style(1)) Old Exp:set %UK_win_sort -oe | sort.jack
  .$iif(%UK_win_sort == -ne,$style(1)) New Exp:set %UK_win_sort -ne | sort.jack
  .$iif(%UK_win_sort == -ge,$style(1)) Gained Exp:set %UK_win_sort -ge | sort.jack
  .-
  .$iif(%UK_win_sort == -ra,$style(1)) Rank:set %UK_win_sort -ra | sort.jack
  .$iif(%UK_win_sort == -us,$style(1)) User:set %UK_win_sort -us | sort.jack
}

Joined: Aug 2008
Posts: 16
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Aug 2008
Posts: 16
bump


Link Copied to Clipboard