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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3. // @Modified build 239 cm19981202
  4. // @Modified build 275 cm19990315 - update recent files on rename
  5. // @Modified build 290 cm19990426 - added DoUpdate function
  6.  
  7. /**
  8. @Tool: renameFile~displays a dialog to allow you to 
  9. rename the active editor.
  10. @EndTool: 
  11. @Summary: renameFile~rename the active editor
  12. */
  13.  
  14. function DoUpdate(cmdUI) 
  15.     cmdUI.enable(getActiveEditor() != null);
  16. }
  17.  
  18. function DoCommand()
  19. {
  20.     var editor = getActiveEditor();
  21.     if (editor)
  22.     {
  23.         var file = editor.GetFile();
  24.         if (file.exists) //cm19981202
  25.         {
  26.             var newFile = confirmFile("Rename the file", "", file, "*.*");
  27.             if (newFile)
  28.             {
  29.                 editor.rename(newFile.path);
  30.                 
  31.                 //cm19990315
  32.                 var recentFilesScript = getScriptObject("\\EventHandlers\\Menu Handlers\\onRecentFiles.script");
  33.                 if (recentFilesScript)
  34.                 {
  35.                     recentFilesScript.AddRecent(editor.path);
  36.                 }
  37.             }
  38.         }
  39.         else
  40.         {
  41.             alert("Cannot rename an untitled file");
  42.         }
  43.     }
  44. }
  45.  
  46. !!/Script
  47.  
  48.