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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: unwrap~removes new lines from the selected text. To 
  6. use select one or more lines and then run the script. 
  7. @See: wrap@Tools Reference/Tools/Misc.html#wrap 
  8. @EndTool: 
  9. @Summary: unwrap~removes new lines from the selected text 
  10. */
  11.  
  12. function DoCommand()
  13. {
  14.   var editor = getActiveEditor();
  15.   if (editor)
  16.   {
  17.     var selection = editor.getSelection();
  18.         editor.select(selection.startLineIndex, 0);
  19.     
  20.     for (var lineIndex = selection.endLineIndex - 2; 
  21.       lineIndex >= selection.startLineIndex; lineIndex--)
  22.     {
  23.             var line = editor.copy(lineIndex+1);
  24.             var index = 0;
  25.             var value = line.charAt(index);
  26.             while (index < line.length && (value == ' ' || value == '\t'))
  27.             {
  28.                 index += 1;
  29.                 value = line.charAt(index);
  30.             }
  31.             
  32.       editor.replace("", lineIndex, 32000, lineIndex+1, index);
  33.     }
  34.     
  35.         
  36.     editor.setActive("Unwrap Lines");
  37.   }
  38. }
  39.  
  40. !!/Script
  41.