Auto script-file text locator

By grasshopper on Nov 17, 2009

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-) }


Sign in to comment.
Cracker200   -  Nov 18, 2009

and /me pee's on p0tat3rs

Cracker200   -  Nov 18, 2009


p0tat3rs   -  Nov 18, 2009

It wouldn't hurt to have the script search through *.ini files as well... as some users tend to save their scripts with that extension. I'm a tad too lazy to look at the actual functionality of the code, but as far as looking clean goes: not too bad, though I'd advise against use of "|".

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.