Project

General

Profile

Filter » History » Version 22

Per Amundsen, 02/16/2023 12:38 PM

1 1 Per Amundsen
_Added in 1.9.4_
2
3 18 Per Amundsen
*/filter [-asdfhHNkwxnpriocteubglLzNDE] [n-n2] [c s] <infile | dialog id> <outfile | dialog id | alias> [alias] <matchtext>*
4 2 Per Amundsen
5 3 Per Amundsen
Scans lines of text in a window, file or dialog control, any matches are then written out to another window, file, or dialog control. 
6
The order of the switch are important, they define what is the infile and what is the outfile, see the examples for more information. 
7
8 6 Per Amundsen
You can filter blank lines by specifying [[$crlf]] for the matchtext.
9
10 3 Per Amundsen
The [[$filtered]] identifier will retrieve the number of matches found.
11
12 1 Per Amundsen
*Switches*
13
14 22 Per Amundsen
table(ktable).
15
|*Switch*|*Description*|
16
| -w | Indicates the parameter is a window. |
17
| -f | Indicates the parameter is a file. |
18
| -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. |
19
| -x | Excludes matching lines. |
20
| -n | Prefixes lines with a line number. (the Nth match) |
21
| -d | *TODO* |
22
| -s | Indicates the status window will be used. |
23
| -p | *TODO* *(AdiIRC always wraps lines)* |
24
| -r | Specifies the range of lines n to n2 for filtering. |
25
| -b | Strips any [[Formatting_Text<notextile>|</notextile>control codes]] when matching text. |
26
| -g | Indicates the matchtext is a [[Scripting_Regex<notextile>|</notextile>regular expression]]. |
27
| -z | Retains line colors when filtering between custom windows. |
28
| -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. |
29
| -i | Indicates that you have provided a [dialog id] custom dialog control as the input. |
30
| -o | Indicates that you have provided a [dialog id] custom dialog control as the output. |
31
| -c | Clears the output window/file before writing to it. |
32
| -t | Sorts the output based on [c s], column C using character S as the columns separator. |
33
| -e | Used with -t, specifies a descending sort. |
34
| -u | Used with -t, specifies a numeric sort. |
35
| -l | Filters from the side-listbox in the first window. |
36
| -L | Filters to the side-listbox in the second window. |
37
| -hN | *TODO* |
38
| -H | Halt the running /filter loop if used inside the [alias]. *(AdiIRC only)* |
39
| -N | Keep the nickcolumn character when filtering from a window. *(AdiIRC only)* |
40
| -E | Filters from the [[Editbox_Control<notextile>|</notextile>Editbox]] up/down history in the first window. *(AdiIRC only)* |
41
| -D | Filters to the [[Editbox_Control<notextile>|</notextile>Editbox]] up/down history in the second window. *(AdiIRC only)* |
42 19 Per Amundsen
43
*Parameters*
44 3 Per Amundsen
45 22 Per Amundsen
table(ktable).
46
|*Parameter*|*Description*|
47
| [n | n2] - if -r is used, indicates the range of lines to be scanned* |
48
| [c s] | if -t is used, indicates how to do the sort |
49
| <infile <notextile>|</notextile> 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) |
50
| <outfile <notextile>|</notextile> dialog id <notextile>|</notextile> 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) |
51
| [alias] | Optional alias called if -a is used. |
52
| <matchtext> | The expression used for the search, if [[$null]] is used, it matches everything. |
53 3 Per Amundsen
54 10 Per Amundsen
*Example*
55
56 3 Per Amundsen
<pre>
57 8 Per Amundsen
;Filter from the file "c:\my file.txt" to the custom window @mywin.
58 3 Per Amundsen
/filter -fw "c:\my file.txt" @mywin *findthis*
59
60 8 Per Amundsen
;Filter from the custom window @mywin to the file "c:\my file.txt".
61 3 Per Amundsen
filter -wf @mywin "c:\my file.txt" *findthat*
62
63 8 Per Amundsen
;Filter from the status window to the single message window.
64 3 Per Amundsen
/filter -sd *findthis*
65
66 8 Per Amundsen
;Filter from the single message window to the status window.
67 3 Per Amundsen
/filter -ds *findthat*
68
69 8 Per Amundsen
;Filter from the filename @this_is_a_file to the dialog 'dialog', id '1'.
70 1 Per Amundsen
/filter -fo @this_is_a_file dialog 1 *findthis*
71
72 8 Per Amundsen
;Filter from a file and call an alias for each line.
73 1 Per Amundsen
/filter -fk file myalias *findthat*
74
75 8 Per Amundsen
;Filter from a file to a file using regex.
76 1 Per Amundsen
/filter -ffg file1 file2 /regex here/
77 8 Per Amundsen
78 9 Per Amundsen
alias sortexample {
79
  ;Create 2 windows.
80
  /window @asd1
81
  /window @asd2
82 1 Per Amundsen
83 9 Per Amundsen
  ;Add some unordered lines.
84
  aline @asd1 cccc3|cccc2|cccc1
85
  aline @asd1 aaaa3|aaaa2|aaaa1
86
  aline @asd1 bbbb3|bbbb2|bbbb1
87
88
  ;Sort by column "1" where column separator is "|" (ascii char 124). (equal to $gettok(cccc3|cccc2|cccc1, 1, 124))
89
  /filter -twwc 1 124 @asd1 @asd2
90
}
91 3 Per Amundsen
</pre>