This code searches all loaded *.mrc files for the search string.
If the search string is found, each occurrence of the search string,
along with the file name and line number, is displayed in a custom window.
Furthermore, double-clicking a line in the custom window will automatically
open the corresponding script file and place the cursor at the beginning of
the line containing the search term.
I also use similar code to list every occurrence of an alias, which I find
particularly useful in debugging.
I hope it works OK for others.
; Usage : /searchfor sometext
; and double-click an item in the resulting window
alias searchfor {
window -l -t30 @search | clear @search
%scripts = $script(0)
%searchTerm = $$1-
while %scripts {
filter -fkn $script(%scripts) extract *
dec %scripts
}
}
on *:close:@search: {
unset %scripts
unset %searchterm
}
alias extract {
if %searchterm isin $1- {
aline @search 4 $+ $script(%scripts)12 $chr(9) $+ 12 $+ $1-
}
}
menu @search {
dclick: {
var %selected = $line(@search,$1,1)
tokenize 32 %selected
var %scriptFile = $strip($1)
var %scriptline = $strip($2)
var %nopath = $nopath(%scriptfile)
clipboard %nopath
showmirc -s
sendkeys % $+ r $+ % $+ r $+ ^ $+ m $+ ^ $+ v $+ {enter}
timer -m 1 500 /gotoLine %scriptLine
}
}
alias -l gotoLine {
clipboard $1
sendkeys ^ $+ g $+ ^ $+ v $+ {enter}
}
alias -l sendkeys {
var %object = sendkeys $+ $ticks
.comopen %object WScript.Shell
if ($com(%object)) { .comclose %object $com(%object,SendKeys,3,bstr,$1-) }
}