home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / SKIPCLOSEPARENTH.SCRIPT < prev    next >
Encoding:
Text File  |  1999-07-29  |  907 b   |  43 lines

  1. !!Script
  2. // Script by Will Hains
  3.  
  4. //
  5. // Skips the next character if it is a close parenthesis,
  6. // otherwise inserts a close parenthesis.
  7. //
  8.  
  9. function DoCommand()
  10. {
  11.   var editor = getActiveEditor();
  12.   if(editor) {
  13.     var range = editor.getSelection();
  14.     
  15.     var startLine = range.startLineIndex;
  16.     var startChar = range.startCharIndex;
  17.     var endLine = range.endLineIndex;
  18.     var endChar = range.endCharIndex;
  19.     
  20.     if((startLine == endLine) && (startChar == endChar)) {
  21.       if(editor.copy(endLine, endChar, endLine, endChar + 1) == ")") {
  22.         editor.select(endLine, endChar + 1, endLine, endChar + 1);
  23.       }
  24.       else {
  25.         editor.remove(range);
  26.         editor.insert(
  27.           startLine, startChar,
  28.           ")"
  29.         );
  30.       } 
  31.     } 
  32.     else {
  33.       editor.replace(")", range);
  34.     } 
  35.   } 
  36.   
  37.   editor.setActive();
  38.   
  39. }
  40.  
  41. !!/Script
  42.  
  43.