home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Misc / findInOpenDocuments.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  1.9 KB  |  76 lines

  1. !!script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: findInOpenDocuments~finds a findWhat expression in all open documents. 
  6. @EndTool: 
  7. @Summary: findInOpenDocuments~finds a findWhat expression in all open documents
  8. */
  9.  
  10. var output = getOutput("Find In Files 1");
  11.  
  12. function DoCommand()
  13. {
  14.     var findParameters = getGlobal("FindParameters", null);
  15.     
  16.     var findData = chooseFindParameters("Find in open windows", findParameters.findWhat, 
  17.         findParameters.caseSensitive, findParameters.wholeWord, 
  18.         findParameters.regularExpression, findParameters.searchDown);
  19.     
  20.     if (findData)
  21.     {   
  22.         findParameters.findWhat = findData.key; 
  23.         findParameters.caseSensitive = findData.caseSensitive;  
  24.         findParameters.wholeWord = findData.wholeWord;  
  25.         findParameters.regularExpression = findData.regularExpression;   
  26.         findParameters.searchDown = findData.searchDown;
  27.         findParameters.updateHistory();
  28.         
  29.         output.clear();
  30.         output.writeLine("Searching for: " + findData.key);
  31.         
  32.         var count = 0;
  33.         var index = 0;
  34.         var lineIndex = -1;
  35.         var editor = getEditor(index++);
  36.         while (editor)
  37.         {
  38.             var fileName = editor.path;
  39.             
  40.             if (findData.searchDown)
  41.             {
  42.                 findData.startCharIndex = 0;
  43.                 findData.startLineIndex = 0;
  44.             }
  45.             else
  46.             {
  47.                 findData.startLineIndex = editor.getLineCount() - 1;
  48.                 findData.startCharIndex = 32000;
  49.             }
  50.             
  51.             editor.findNext(findData);
  52.             while (findData && findData.found)
  53.             {
  54.                 var range = findData.range;
  55.                 
  56.                 // Only print out one message per line
  57.                 if (lineIndex != range.startLineIndex)
  58.                 {
  59.                     lineIndex = range.startLineIndex;
  60.                     output.writeMessage(fileName, lineIndex, editor.copy(lineIndex));
  61.                     count += 1;
  62.                 }
  63.                 
  64.                 editor.findNext(findData);
  65.             }
  66.             
  67.             lineIndex = -1;
  68.             editor = getEditor(index++);
  69.         }
  70.         output.writeLine("Found " + count + " items");
  71.     }
  72. }
  73.  
  74. !!/script
  75.  
  76.