Added in 1.9.4

/filter [-asdfhHNkwxnpriocteubglLzNDE] [n-n2] [c s] <infile | dialog id> <outfile | dialog id | alias> [alias] <matchtext>

Scans lines of text in a window, file or dialog control, any matches are then written out to another window, file, or dialog control.
The order of the switch are important, they define what is the infile and what is the outfile, see the examples for more information.

You can filter blank lines by specifying $crlf for the matchtext.

The $filtered identifier will retrieve the number of matches found.


Switch Description
-w Indicates the parameter is a window.
-f Indicates the parameter is a file.
-a Sorts filtered lines by calling the optional [alias] parameter, the alias is passed two lines, $1 and $2, it must compare both and return -1, 0, or 1 to indicate relative sort order of these lines to each other.
-x Excludes matching lines.
-n Prefixes lines with a line number. (the Nth match)
-s Indicates the status window will be used.
-p TODO (AdiIRC always wraps lines)
-r Specifies the range of lines n to n2 for filtering.
-b Strips any control codes when matching text.
-g Indicates the matchtext is a regular expression.
-z Retains line colors when filtering between custom windows.
-k Indicates that you have specified an <alias> as the output instead of a window name. The alias will be called with the result of each filtered line with the form $<alias>($1) where $1 is the matched line.
-i Indicates that you have provided a [dialog id] custom dialog control as the input.
-o Indicates that you have provided a [dialog id] custom dialog control as the output.
-c Clears the output window/file before writing to it.
-t Sorts the output based on [c s], column C using character S as the columns separator.
-e Used with -t, specifies a descending sort.
-u Used with -t, specifies a numeric sort.
-l Filters from the side-listbox in the first window.
-L Filters to the side-listbox in the second window.
-H Halt the running /filter loop if used inside the [alias]. (AdiIRC only)
-N Keep the nickcolumn character when filtering from a window. (AdiIRC only)
-E Filters from the Editbox up/down history in the first window. (AdiIRC only)
-D Filters to the Editbox up/down history in the second window. (AdiIRC only)


Parameter Description
[n n2] - if -r is used, indicates the range of lines to be scanned*
[c s] if -t is used, indicates how to do the sort
<infile | dialog id> if no switch implies a window's name to be use as the infile, you must provide an infile (a window, a file, or a dialog control)
<outfile | dialog id | alias> if no switch implies a window's name to be used as the outfile, you must provide an outfile (a window, a file, a dialog control, or an alias name if -k is used)
[alias] Optional alias called if -a is used.
<matchtext> The expression used for the search, if $null is used, it matches everything.


;Filter from the file "c:\my file.txt" to the custom window @mywin.
/filter -fw "c:\my file.txt" @mywin *findthis*

;Filter from the custom window @mywin to the file "c:\my file.txt".
filter -wf @mywin "c:\my file.txt" *findthat*

;Filter from the status window to the single message window.
/filter -sd *findthis*

;Filter from the single message window to the status window.
/filter -ds *findthat*

;Filter from the filename @this_is_a_file to the dialog 'dialog', id '1'.
/filter -fo @this_is_a_file dialog 1 *findthis*

;Filter from a file and call an alias for each line.
/filter -fk file myalias *findthat*

;Filter from a file to a file using regex.
/filter -ffg file1 file2 /regex here/

alias sortexample {
  ;Create 2 windows.
  /window @asd1
  /window @asd2

  ;Add some unordered lines.
  aline @asd1 cccc3|cccc2|cccc1
  aline @asd1 aaaa3|aaaa2|aaaa1
  aline @asd1 bbbb3|bbbb2|bbbb1

  ;Sort by column "1" where column separator is "|" (ascii char 124). (equal to $gettok(cccc3|cccc2|cccc1, 1, 124))
  /filter -twwc 1 124 @asd1 @asd2

Updated by Per Amundsen over 1 year ago · 22 revisions

Also available in: PDF HTML TXT