From WikiChip
Difference between revisions of "mirc/commands/filter"
< mirc‎ | commands

m (Bot: de-linking old mIRC menu)
Line 1: Line 1:
 
{{mirc title|/filter Command}}
 
{{mirc title|/filter Command}}
The '''/filter command''' scans lines of text in a window or file, or dialog control, and if any of them matcht the matchext, they are written out to another window or file, or another dialog control which you can then use. The order of the switch are important, they define what is the infile and what is the outfile, see the examples for more informations. You can filter blank lines by specifying {{mIRC|$crlf}} for the matchtext. /filter also fills the {{mIRC|$filtered}} identifier with the number of matches found, if any.
+
The '''/filter command''' is perhaps the most powerful and least understood script command in mIRC. It scans lines of text in a custom-window or file or dialog control, and any lines that match the matchtext are written out to another custom-window or file or dialog control. You can restrict the source to a range of line numbers, and you can sort the output using an alias. It will also work correctly when the source and destination windows are the same, allowing you easily and efficiently to sort the contents of a window. The order of the switch values is important as they define the source and destination of lines; see the examples for more informations. You can filter blank lines by specifying {{mIRC|$crlf}} for the matchtext. /filter also fills the {{mIRC|$filtered}} identifier with the number of matches found.
  
 
== Synopsis ==
 
== Synopsis ==

Revision as of 03:22, 15 October 2017

The /filter command is perhaps the most powerful and least understood script command in mIRC. It scans lines of text in a custom-window or file or dialog control, and any lines that match the matchtext are written out to another custom-window or file or dialog control. You can restrict the source to a range of line numbers, and you can sort the output using an alias. It will also work correctly when the source and destination windows are the same, allowing you easily and efficiently to sort the contents of a window. The order of the switch values is important as they define the source and destination of lines; see the examples for more informations. You can filter blank lines by specifying $crlf for the matchtext. /filter also fills the $filtered identifier with the number of matches found.

Synopsis

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

Switches

  • -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)
  • -d - indicates the single message window will be used
  • -s - indicates the status window will be used
  • -p - wraps the text output in a custom window
  • -hN - indents wrapped text when the -p switch is used by N spaces (same as echo -i)
  • -r - specifies the range of lines n to n2 for filtering
  • -b - strips BURK 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 - switch clears the output window/file before writing to it
  • -t - switch 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

Parameters

  • [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.

Example

;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/
;sort by file(same file) - Input file's Column 1 delimited by Space Character $chr(32)
/filter -ffcut 1 32 file.txt file.txt 
; If /window -jN not used or created with -j0, size limit of @test is current value of Mirc-Options/Other/WindowBuffer
//filter -fwc versions.txt @test * | var %missing $calc( $filtered - $line(@test,0)) | if (%missing) echo -a warning %missing of $filtered filtered lines not in @test because /window not used with large enough -jN value

Compatibility

Added: 5.3

See also

v · d · e mIRC commands list

A /abook, /action, /add, /ajinvite, /alias, /aline, /ame, /amsg, /anick, /aop, /auser, /auto, /autojoin, /avoice, /away

B /background, /ban, /bcopy, /beep, /bindip, /bread, /break, /breplace, /bset, /btrunc, /bunset, /bwrite

C /channel, /clear, /clearall, /clearial, /cline, /clipboard, /close, /closechats, /closedccs, /closefserves, /closemsg, /cnick, /color, /colour, /comclose, /comlist, /commands, /comopen, /comreg, /continue, /copy, /creq, /ctcp, /ctcpreply, /ctcps

D /dcc, /dccserver, /dde, /ddeserver, /debug, /dec, /describe, /dialog, /did, /didtok, /disable, /disconnect, /dlevel, /dline, /dll, Template:mIRC/donotdisturb, /dns, /dqwindow, /drawcopy, /drawdot, /drawfill, /drawline, /drawpic, /drawrect, /drawreplace, /drawrot, /drawsave, /drawscroll, /drawsize /drawtext

E /ebeeps, /echo, /editbox, /else, /elseif, /emailaddr, /enable, /events, /exit

F /fclose, /filter, /findtext, /finger, /firewall, /flash, /flist, /flood, /flush, /flushini, /fnord, /font, /fopen, /fseek, /fsend, /fserve, /fullname, /fupdate, /fwrite

G /ghide, /gload, /gmove, /gopts, /goto, /gplay, /gpoint, /gqreq, /groups, /gshow, /gsize, /gstop, /gtalk, /gunload, /guser

H /hadd, /halt, /haltdef, /hdec, /hdel, /help, /hfree, /hinc, /hload, /hmake, /hotlink, /hop, /hsave

I /ial, /ialclear, /ialmark, /identd, /if, /ignore, /iline, /inc, /iuser

J /join

L /leave, /linesep, /links, /list, /load, /loadbuf, /localinfo, /log, /logview

M /maxdepth, /mdi, /me, /menubar, /mkdir, /mnick, /mode, /msg

N /noop, /notice, /notify

O /onotice, /omsg

P /pareline, /part, /partall, /pdcc, /perform, /play, /playctrl, /pop, /protect, /proxy, /pvoice

Q /qme, /qmsg, /query, /queryrn, /quit, /quote

R /raw, /registration, /reload, /remini, /remote, /remove, /rename, /renwin, /reseterror, /resetidle, /return, /returnex, /rlevel, /rline, /rmdir, /run, /ruser

S /save, /savebuf, /saveini, /say, /scid, /scon, /server, /set, /setlayer, /showmirc, /signal, /sline, /sockaccept, /sockclose, /socklist, /socklisten, /sockmark, /sockopen, /sockpause, /sockread, /sockrename, /sockudp, /sockwrite, /sound, /speak, /splay, /sreq, /strip, /switchbar

T /timer, /timestamp, /tip, /tips, /titlebar, /tnick, /tokenize, /toolbar, /topic /tray, /treebar

U /ulist, /unload, /unset, /unsetall, /updatenl, /url, /username, /uwho

V /var, /vcadd, /vcmd, /vcrem, /vol

W

X /xyzzy