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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: removeEmptyLines~removes all empty lines
  6. from the current selection. To use select multiple 
  7. lines and then run the script.
  8. @See: wrap@Tools Reference/Tools/Misc.html#wrap 
  9. @See: wrap@Tools Reference/Tools/Misc.html#unwrap 
  10. @EndTool: 
  11. @Summary: removeEmptyLines~removes empty lines 
  12. */
  13.  
  14. function DoCommand()
  15. {
  16.   var editor = getActiveEditor();
  17.   if (editor)
  18.   {
  19.     var selection = editor.getSelection();
  20.     RemoveLines(editor, selection.startLineIndex, selection.endLineIndex);
  21.   }
  22.   editor.setActive("Remove Empty Lines");
  23. }
  24.  
  25. function RemoveLines(editor, start, end)
  26. {
  27.   var lineIndex = end
  28.   while (lineIndex >= start)
  29.   {
  30.     var length = editor.getLineLength(lineIndex);
  31.     if (length == 0)
  32.     {
  33.       editor.remove(lineIndex, 0, lineIndex + 1, 0);
  34.     }
  35.     lineIndex -= 1;
  36.   }
  37. }
  38. !!/Script
  39.  
  40.