X
mIRCScripts.net
Welcome to mIRCScripts.net! By using this site, you understand and agree to this site using cookies.
7:13:30 am - Wednesday September 26th, 2018
Search:     Cat:   
Downloads
Support
Portal
Stats
  • Total Hits: 127,739
  • Today's Hits: 221
  • Most Hits: 7/6/2018
  • Dynamic Hits: 3,394
  • Total Downloads: 552
  • Today's Downloads: 4
  • Newest: Korona
  • Members Online: 3/41
  • Guests Online: 6
Affiliates








Snippets

Search scripts for matchtext or mismatched Pairs v1.2

A quick tool to help find script errors due to mismatched braces/symbols!
Search *.remote-scripts and *.aliases-files for matching text
or
Find lines with (mis-matched parenthesis) or [square quotes]

If only searching for 1 'word', assumes all-files: /srch :TEXT
otherwise if 2+ parameters, assumes 1st is filespec: /srch foo*.mrc :sock
Regex search script for trailing spaces: /srch -r * \s$

Uploaded By: maroon
Author: maroon
Added: 3/25/2018
Last Updated: 8/21/2018
mIRC Version: used 6.35 & 7.51+
Hits: 279
Size: 7.1KB
Downloads: 18
Review By: entropy


    
  2    0


Source Code:
  1. ; Srch / Pairs v1.2 by maroon
  2. ; Srch: hunt for alias or code quickly, instead of manually searching each script one-by-one
  3. ; Pairs: find most mis-matched parenthesis and square-brackets
  4. ; Both scripts search all REMOTE-tab scripts - then search all ALIASES-tab files.
  5. ; "pairs" searches for lines with unmatched parenthesis and [braces]
  6. ; "srch" searches your scripts for the string
  7. ; /pairs 1stChar 2ndChar [WildcardFilename]
  8. ; /pairs ( ) filename
  9. ; /pairs ( ) wild*card*filename
  10. ; If /pairs 3rd parameter is missing, uses * as filespec
  11. ; /pairs [ ]
  12. ; /srch [-r] <filename> <more than 1 text words that can have wildcards>
  13. ; the regex search defaults to case-sensitive unless enabling the 'i' flag. (Regex match not highlighted)
  14. ; If only searching for 1 'word', then filename is optional, and assumed to be *
  15. ; search script1.mrc for word1 word2: /srch script1.mrc word1 word2
  16. ; search all files for label beginning with 'sock': /srch :sock
  17. ; case-insensitive search all files: /srch -r * /srch/i
  18. ; for faster speed, loading entire script into @window, making impossible
  19. ;
  20. ; v1.1=-j99999 to override window size limit, notice about .ini
  21. ; v1.2= Hid n123= from .ini display. Added -r switch=regex. Don't force text color in case of black background. Srch shows filenames only if has matches.
  22.  
  23. alias srch {
  24. ; change this to -ag to instead show to active window -> | var %echotarget -sg
  25. var %regex 0 | if ($1 == -r) { var %regex 2 | tokenize 32 $2- }
  26. if ($0 == 1) tokenize 32 * $1 | var %sc $color(notice) , %screv $+($chr(3),0,$chr(44),%sc)
  27. echo %sc %echotarget =/=/=/=/=/=/=
  28. echo %sc %echotarget /srch by maroon $+ $chr(169) searches scripts/aliases.ini for text. Syntax: "/srch ScriptName/wildcard one-or-more-searchwords" or "/srch OneWordSearchText" or "/srch -r ScriptName RegexPattern"
  29. echo %sc %echotarget Display: $+(#Match:,$chr(22),Line#,$chr(22)) $+(script line,$chr(22),matchtext,$chr(22),script line)
  30. echo %sc %echotarget Example: /srch * :sock (find event or label begins with 'sock')
  31. echo %sc %echotarget Example: /srch alias*srch (assumes 1 word is search term in all files)
  32. echo %sc %echotarget Example: /srch -r * \s$ (find script lines with trailing space)
  33. if (!$0) return | var %totalscripts $script(0) , %s -1 , %s_or_a 1
  34. echo %echotarget =/=/=/=/=/=/= $chr(3) $+ 0,12 This search: $iif(%regex,[Regex]) /srch $1- $chr(9)
  35. var %ticks $ticks , %win @maroon_temp, %MatchCount 0 , %ScriptsWithMatch 0 , %searchedcount 0 | window -hj99999 %win | clear %win
  36. while (%s < %totalscripts) {
  37. inc %s | if (%s == 0) goto top | ;var %f $remove($iif(%s_or_a,$script(%s),$alias(%s)),$mircdir)
  38. var %f $iif(%s_or_a,$script(%s),$alias(%s)) , %flag 1
  39. if (!$file(%f).size) echo %echotarget %screv Warning: loaded file does not exist or is zero size: %f $chr(3)
  40. elseif ($+(*,$1,*) iswm %f) {
  41. filter -fwc $qt(%f) %win * | var %i 1 , %line 1 , %matchflag 1 | inc %searchedcount
  42. while (%line) {
  43. if (%regex) var %line $fline(%win,$2-,%i,%regex)
  44. else var %line $fline(%win,$+(*,$2-,*),%i,%regex)
  45. var %linetext $line(%win,%line)
  46. if ((*.ini iswm %f) && (%line)) { var %linetext $gettok(%linetext,2-,32)
  47. if (%regex) { if (!$regex(junk,%linetext,$2-)) var %line }
  48. elseif ($+(*,$2-,*) !iswm %linetext) var %line
  49. }
  50. if (%line != $null) {
  51. if (%flag) { var %flag | echo %sc %echotarget %screv %s searching-> %f $chr(3) $iif(*.ini iswm %f,You can remove 'n1234=' from scripts/aliases by renaming to another filetype besides .ini) }
  52. inc %matchcount | inc %ScriptsWithMatch %matchflag | var %matchflag 0
  53. if (%regex) echo %sc %echotarget $+($chr(35),%matchcount,:,$chr(22),%line,$chr(22)) %linetext
  54. else echo %sc %echotarget $+($chr(35),%matchcount,:,$chr(22),%line,$chr(22)) $replace(%linetext,$2-,$+($chr(22),$2-,$chr(22)))
  55. inc %i }
  56. }
  57. }
  58. :top
  59. if ((%s == %totalscripts) && (%s_or_a)) { var %s 0, %totalscripts $alias(0) , %s_or_a 0 }
  60. }
  61. echo %echotarget %screv Finished! $calc($ticks - %ticks) $+ ms $chr(9) Matches: %matchcount in %ScriptsWithMatch files out of %searchedcount searched files. Total Scripts: $script(0) Aliases: $alias(0) $chr(3) | :exit | window -c %win
  62. }
  63.  
  64. alias pairs {
  65. ; change this to -ag to instead show to active window -> | var %echotarget -sg
  66. if (($len($1) == 1) && ($len($2) == 1) && ($1 !isnum) && ($2 !isnum)) tokenize 32 $asc($1) $asc($2) $iif($3-,$3-,*)
  67. if ($0 isnum 0-1) tokenize 32 40 41 $iif($1,$1,*) | var %sc $color(notice) , %screv $+($chr(3),0,$chr(44),%sc)
  68. echo %sc %echotarget =/=/=/=/=/=/=
  69. echo %sc %echotarget Pairs by maroon $+ $chr(169) warns of different counts of a pair of ASCII numbers. Syntax: "/pairs ASCIInumber ASCIInumber scriptname/wildcard" or "/pairs Char1 Char2 *" or "/pairs ( )" or "/pairs [ ]"
  70. echo %sc %echotarget False alarms include $chr(22) emoticons like :) $chr(22) or $chr(22) lines divided across $ $+ & $chr(22) or $chr(22) 1 side of pair using $ $+ chr(N) i.e. $ $+ chr(40) with ) $chr(22) <- these mis-matches causes this line to be reported by this script as 2-vs-4
  71. echo %sc %echotarget Suggest fixing from the bottom upwards if add/removing lines
  72. echo %sc %echotarget Displays: Count1-vs-Count2 $+(Line:,$chr(22),N,$chr(22)) script-line
  73. echo %sc %echotarget =/=/=/=/=/=/= Example: /pairs ( ) * $chr(3) $+ 0,12 Current Search: /pairs $1 $2 $iif($3- == *,*, $+(*,$3-,*) ) $chr(9)
  74. var %ticks $ticks , %win @maroon_temp , %s 0 , %totalscripts $script(0) , %s_or_a 1 , %mismatches 0 , %searchedcount 0 , %foundincount 0
  75. window -hj99999 %win | if (!$2) tokenize 32 40 41 $iif($1,$1,*) | if (($1 !isnum 1-65535) || ($2 !isnum 1-65535)) goto exit
  76. while (%s < %totalscripts) {
  77. inc %s | if (%s == 0) goto top | ;var %f $remove($iif(%s_or_a,$script(%s),$alias(%s)),$mircdir)
  78. var %f $iif(%s_or_a,$script(%s),$alias(%s))
  79. if (!$file(%f).size) echo %echotarget %screv Warning: loaded file does not exist or is zero size: %f $chr(3)
  80. elseif ($+(*,$3-,*) iswm %f) {
  81. inc %searchedcount | filter -fwc $qt(%f) %win * | var %i 1 , %tl $line(%win,0) , %foundflag 1
  82. echo %echotarget %screv %s searching-> %f $chr(3) $iif(*.ini iswm %f,You can remove 'n1234=' from scripts/aliases by renaming to another filetype besides .ini)
  83. while (%i < %tl) {
  84. inc %i | var %text $line(%win,%i) | if (*.ini iswm %f) var %text $gettok(%text,2-,32)
  85. if ($count(%text,$chr($1)) != $count(%text,$chr($2))) {
  86. inc %mismatches | inc %foundincount %foundflag | var %foundflag 0
  87. echo %echotarget $+($v1,-vs-,$v2) $+(Line:,$chr(22),%i,$chr(22)) %text
  88. }
  89. }
  90. }
  91. :top
  92. if ((%s == %totalscripts) && (%s_or_a)) { var %s 0, %totalscripts $alias(0) , %s_or_a 0 }
  93. }
  94. echo %echotarget %screv Finished! $calc($ticks - %ticks) $+ ms Found %mismatches Mismatches in %foundincount of %searchedcount searched files. Scripts: $script(0) Aliases: $alias(0) $chr(3) | :exit | window -c %win
  95. }
  96.  


Comments
No Comments.