mIRC Homepage
Posted By: CtrlAltDel yet another /filter question - 07/03/06 08:01 PM
I have a popup (nicklist) that works, but it shows the first 100 instances of what someone said in my channel's buffer. Is there a way to show just the last 50 instead? Maybe in reverse order?
Code:
Track: {
  var %win = $+(@,$$1),%input = $chan
  window -exnk0 %win
  filter -wwpr 1-100 %input %win $+(*,$$1,*)
}
 


Any help is (as always) appreciated.
Posted By: hixxy Re: yet another /filter question - 08/03/06 12:10 AM
Code:
Track: {
  set -u %win @ $+ $$1
  window -eknx %win
  filter -rwk 1-50 $chan addtowin * $+ $$1*
}


Then outside of popupmenu you need to add this alias:

Code:
alias addtowin {
  if ($window(%win)) iline -p %win 1 $1-
}
Posted By: CtrlAltDel Re: yet another /filter question - 08/03/06 12:31 AM
I copy/pasted yours, and the output is just one line (first one in the buffer) and nothing else.
Posted By: hixxy Re: yet another /filter question - 08/03/06 12:41 AM
It seems the /set -u behaviour has changed since 6.16 frown

This one works:

Code:
menu nicklist {
  Track: {
    set %win @ $+ $$1
    window -eknx %win
    filter -rwk 1-50 $chan addtowin * $+ $$1*
    unset %win
  }
}
alias addtowin {
  if ($window(%win)) iline -p %win 1 $1-
}
Posted By: CtrlAltDel Re: yet another /filter question - 08/03/06 12:53 AM
I don't think I was clear enough with my first request.
That one is giving me the things said by the person in the first 50 lines of my buffer (2 days ago in one channel). What I'd like to do is get the last 50 lines of the buffer (in reverse order) ie:
what was said 2 minutes ago
what was said 5 minutes ago
what was said 6 minutes ago

etc.
Posted By: DaveC Re: yet another /filter question - 08/03/06 01:01 AM
the original script doesnt give 100 instances of what ever that is said in channel, it gives ever instance in the first 100 lines in the channel buffer, if the channel buffer is 1000 lines then it misses the last 900 lines. frown

alias Track: {
var %win $+(@,$$1), %temp = $+(%win,.temp), %input = $chan
set -u0 %Track.filter.alias.win %win
window -c %win | window -exnk0 %win
window -c %temp | window -hn %temp
filter -wwc %input %temp $+(*,$$1,*)
filter -wwcr $+($iif(($calc($line(%temp,0) - 49) < 1),1,$v1),-,$line(%temp,0)) %temp %temp
filter -wwk %temp Track.filter.alias
window -c %temp
}
alias -l Track.filter.alias { iline -p %Track.filter.alias.win 1 $1- }

* whats it do
filters all instances to a window (%temp)
filters the last 50 only back into %temp
filters to a alias to reverse the order (couldnt think of a better way, im sure there is one but it eludes me right now) leaving them in %win
Posted By: hixxy Re: yet another /filter question - 08/03/06 01:06 AM
Got ya this time. /filter doesn't have reverse filtering functionality so you'll have to use a loop.

Code:
menu nicklist {
  Track: {
    var %i = $fline($chan,* $+ $$1*,0), %l = 0, %win = @ $+ $$1
    window -eknx %win
    while (%i) {
      if (%l &lt; 50) {
        aline -p %win $line($chan,$fline($chan,* $+ $$1*,%i))
        inc %l
      }
      else break
      dec %i
    }
  }
}
Posted By: CtrlAltDel Re: yet another /filter question - 08/03/06 01:37 AM
Yeah, I meant the first 100 lines blush

Code:
alias -l Track.filter.alias { iline -p %Track.filter.alias.win 1 $1- }  

* /iline: invalid parameters confused
Posted By: CtrlAltDel Re: yet another /filter question - 08/03/06 01:38 AM
perfect! thanks a lot! grin
Posted By: DaveC Re: yet another /filter question - 08/03/06 06:34 AM
Quote:
Yeah, I meant the first 100 lines blush


And now you mean the last 50 ?
thats like totally different from your request.

Quote:
* /iline: invalid parameters confused


I would check if u copied the script correctly, becuase I cant make that happen at all, what mirc version did u use maybe? (mine was 6.16)

Anyway if your request is to get all occrances of $1 in the last 50 lines only, Hixxy's is pretty close, but hes actually giving you the last 50 occurances (same as mine does/should have done)
However using a filter across the whole channel would be significantly faster than using the $fline identifier as the filter internally needs to make one pass across the channel only.
I even attempted to reduce the over all filtered area using a only two $fline's, one to get total occrances then a second that minus 49 from the first to get the line number of the first of the last 50 occrances, all this did is add way more ticks than just hitting the whole channel for matches.

SO This well do the same also IE: give you the LAST 50 occrances in the channel, in reverse order., but should be significantly faster (much more so the more matches there are)

Code:
alias Track: {
  var %win $+(@,$$1), %input = $chan
  window -c %win  | window -exnk0 %win
  filter -wwc %input %win $+(*,$$1,*)
  if ($line(%win,0) &gt; 50) { dline %win $+(1-,$calc($v1 - 50)) }
  var %m = $line(%win,0), %i = %m
  while (%i) { aline -p %win $line(%win,%i) | dec %i }
  dline %win $+(1-,%m)
}


I thought id add this also...
The one below is what I beleive you originally ment to specificy "Any occurance of $1 in the last 50 lines of the channel, in reverse order"
However it might not be what you wanted.
It filters for $1 using only the last 50 lines, then loops to reverse them, and removes the orginal ordered lines.

Code:
alias Track: {
  var %win $+(@,$$1), %input = $chan
  window -c %win  | window -exnk0 %win
  filter -wwcr $+($iif(($calc($line(%input,0) - 49) &lt; 1),1,$v1),-,$line(%input,0)) %input %win $+(*,$$1,*)
  var %m = $line(%win,0), %i = %m
  while (%i) { aline -p %win $line(%win,%i) | dec %i }
  dline %win $+(1-,%m)
}
Posted By: CtrlAltDel Re: yet another /filter question - 08/03/06 08:55 PM
re: the invalid parameters, I'm using 6.17 (and did copy/paste correctly). dunno what caused it.

I have actually ended up using both of your solutions (for different reasons).

Thanks to both of you for taking the time to sort my mess out crazy
© mIRC Discussion Forums