Difference between revisions of "Filter"
From Scriptwiki
(hum...) |
(→Filtering with custom alias) |
||
Line 127: | Line 127: | ||
[[window]] @filtertest2 | [[window]] @filtertest2 | ||
; now lets sort all the numbers and put them to the new window | ; now lets sort all the numbers and put them to the new window | ||
− | filter -aww sortnumber | + | filter -aww @filtertest @filtertest2 sortnumber |
[[Category:Commands]] | [[Category:Commands]] |
Revision as of 22:59, 9 December 2005
This command scans lines of text in a window or file and if any of them contain matchtext, they are written out to another window or file which you can then use.
/filter [-asdfkwxnpriocteubglLz] [n-n2] [c s] <infile | dialog id> <outfile | dialog id | alias> [alias] <matchtext>
The explanation of all switches at first:
Switch | Meaning |
a | sorts filtered lines by calling the optional [alias]. The alias is passed two lines in $1 and $2, it must compare these and return -1, 0, or 1 to indicate relative sort order of these lines to each other. |
s | makes the status window the infile. |
d | makes the single message window the infile. |
f | tells mIRC that the infile is actually a file. |
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. |
w | tells mIRC that the infile is actually a window. |
x | excludes matching lines. |
n | prefixes lines with a line number. |
p | wraps the text output in a custom window. |
r | specifies the range of lines n to n2 for filtering. |
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 | specifies a descending sort. |
u | specifies a numeric sort. |
b | strips BURK codes when matching text. |
g | indicates that matchtext is a regular expression. |
l | filters from the side-listbox in the first window. |
L | filters from the side-listbox in the second window |
z | retains line colors when filtering between custom windows. |
Note that you can filter blank lines by specifying $crlf for the matchtext.
The $filtered identifier is filled with the number of matches found, if any.
Some important facts about /filter:
- If you specify an window as output, it has to be created first. mIRC will not create one. Contrary to that, mIRC will create files, if they do not exist.
- If no matchtext is specified, all lines with be copied.
- The specied windows / files must be in the correct order (-fw copies from file to window, -wf from window to file).
Contents
Example
For some of the examples, you will need:
- a custom window. Open it with /window -e @filtertest
- a text file. Make a blank one with /write -c filtertest.txt
Simple copying from files and windows
; This will copy your entire mIRC.ini in the @filtertest window. filter -fw mIRC.ini @filtertest ; creates another window called @filtertest2, then copies only lines from @filtertest that begin with a open square bracket [. window @filtertest2 | filter -ww @filtertest @filtertest2 [*
; Copies the entire versions.txt to your filtertest window, with clearing it before. filter -cfw versions.txt @filtertest ; Copies all lines with change in it to @filtertest, with clearing it before again. filter -cww @filtertest @filtertest *change*
Filtering lines
; This will filter every line in the Status Window that ends with "Unknown command." into a file called unknown.txt filter -sf unknown.txt *Unknown command.
; Loads all lines from versions.txt into the Status Window filter -fs versions.txt anytext
; Filter only lines 56 to 87 of versions.txt to the Status Window filter -rfs 56-87 versions.txt anytext
Excluding text
; Filters all lines from #help.script to our @filtertest window but exclude lines that contain "you suck" filter -cxww #help.script @filtertest *you suck*
; Remove all lines from #help.script.log that start with -AnnoyingNoticer-. ; Note that ff tells mIRC that we want to filter the files, not the channel window. filter -cxff #help.script.log #help.script.log -AnnoyingNoticer-*
Filtering Dialogs
; Save the contents of a listbox ID 3 in a dialog called "jukebox" to favorites.txt, making sure the text file is cleared before outputting to it filter -cif jukebox 3 favorites.txt
; Example 28: Another similar song list, this time we don't want to save the songs that are in C:\Music\Awful\ filter -xcif jukebox 3 favorites.txt *C:\Music\Awful\*
Filtering nicklist
; Filter the nicklist in the channel #help.script to a custom window called @#help.script_filter filter -lw #help.script @#help.script_filter
Filtering with custom alias
; lets make a little alias comparing two numbers alias sortnumber { return $iif($1 > $2, 1, $iif($1 == $2,0,-1)) }
; now let's fill a window with 1000 random numbers var %i = 1 ; lets loop from 1 to 1000 while (%i <= 1000) { ; and add a random number to the window aline @filtertest $rand(1,999999) inc %i } ; lets make a second custom window window @filtertest2 ; now lets sort all the numbers and put them to the new window filter -aww @filtertest @filtertest2 sortnumber