Project

General

Profile

Filter » History » Version 13

Per Amundsen, 04/13/2016 05:13 PM

1 1 Per Amundsen
_Added in 1.9.4_
2
3 13 Per Amundsen
*/filter [-asdfhNkwxnpriocteubglLz] [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 7 Per Amundsen
-w - Indicates the parameter is a window.
15
-f - Indicates the parameter is a file.
16
-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.
17
-x - Excludes matching lines.
18
-n - Prefixes lines with a line number. (the Nth match)
19 5 Per Amundsen
-d - TODO
20 7 Per Amundsen
-s - Indicates the status window will be used.
21 5 Per Amundsen
-p - TODO
22 7 Per Amundsen
-r - Specifies the range of lines n to n2 for filtering.
23 11 Per Amundsen
-b - Strips any [[Formatting_Text|control codes]] when matching text.
24 12 Per Amundsen
-g - Indicates the matchtext is a [[Scripting_Regex|regular expression]].
25 5 Per Amundsen
-z - TODO
26 7 Per Amundsen
-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.
27
-i - Indicates that you have provided a [dialog id] custom dialog control as the input.
28
-o - Indicates that you have provided a [dialog id] custom dialog control as the output.
29
-c - Clears the output window/file before writing to it.
30
-t - Sorts the output based on [c s], column C using character S as the columns separator.
31
-e - Used with -t, specifies a descending sort.
32
-u - Used with -t, specifies a numeric sort.
33
-l - Filters from the side-listbox in the first window.
34 1 Per Amundsen
-L - Filters to the side-listbox in the second window.
35 13 Per Amundsen
-hN - TODO
36 3 Per Amundsen
37
*Parameters*
38
39
[n-n2] - if -r is used, indicates the range of lines to be scanned*
40
[c s] - if -t is used, indicates how to do the sort
41
<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)
42
<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)
43 1 Per Amundsen
[alias] - optional alias called if -a is used
44 6 Per Amundsen
<matchtext> - the expression used for the search, if [[$null]] is used, it matches everything. 
45 3 Per Amundsen
46 10 Per Amundsen
*Example*
47
48 3 Per Amundsen
<pre>
49 8 Per Amundsen
;Filter from the file "c:\my file.txt" to the custom window @mywin.
50 3 Per Amundsen
/filter -fw "c:\my file.txt" @mywin *findthis*
51
52 8 Per Amundsen
;Filter from the custom window @mywin to the file "c:\my file.txt".
53 3 Per Amundsen
filter -wf @mywin "c:\my file.txt" *findthat*
54
55 8 Per Amundsen
;Filter from the status window to the single message window.
56 3 Per Amundsen
/filter -sd *findthis*
57
58 8 Per Amundsen
;Filter from the single message window to the status window.
59 3 Per Amundsen
/filter -ds *findthat*
60
61 8 Per Amundsen
;Filter from the filename @this_is_a_file to the dialog 'dialog', id '1'.
62 1 Per Amundsen
/filter -fo @this_is_a_file dialog 1 *findthis*
63
64 8 Per Amundsen
;Filter from a file and call an alias for each line.
65 1 Per Amundsen
/filter -fk file myalias *findthat*
66
67 8 Per Amundsen
;Filter from a file to a file using regex.
68 1 Per Amundsen
/filter -ffg file1 file2 /regex here/
69 8 Per Amundsen
70 9 Per Amundsen
alias sortexample {
71
  ;Create 2 windows.
72
  /window @asd1
73
  /window @asd2
74 1 Per Amundsen
75 9 Per Amundsen
  ;Add some unordered lines.
76
  aline @asd1 cccc3|cccc2|cccc1
77
  aline @asd1 aaaa3|aaaa2|aaaa1
78
  aline @asd1 bbbb3|bbbb2|bbbb1
79
80
  ;Sort by column "1" where column separator is "|" (ascii char 124). (equal to $gettok(cccc3|cccc2|cccc1, 1, 124))
81
  /filter -twwc 1 124 @asd1 @asd2
82
}
83 3 Per Amundsen
</pre>