home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Tasks / autoSave.script < prev   
Encoding:
Text File  |  2001-06-19  |  1.8 KB  |  65 lines

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: autoSave~saves all existing documents at a specified interval. 
  6. The initial interval is set to 2 minutes. To change the interval run 
  7. this script. To turn auto save on or off use the preferences dialog.
  8. @EndTool: 
  9. @Summary: autoSave~saves all existing documents at a specified interval
  10. */
  11.  
  12. /////////////////////////////////////////////////////////////////////////
  13. // WARNING: Do not edit this script when autosave is active
  14. // To edit, first turn autosave off using the preference dialog,
  15. // then restart and edit this script. Next turn autosave on and restart.
  16. /////////////////////////////////////////////////////////////////////////
  17.  
  18. var gOutput = getOutput();
  19. var gDuration = 120; // Seconds
  20. var gAutoSave = true;
  21. var gBackupFolder = File.getLibraryPath() + "\\Backup\\";
  22.  
  23. function DoCommand()
  24. {
  25.     var value = prompt("Set auto save interval (seconds)", "" + gDuration);
  26.     if (value)
  27.     {
  28.         gDuration = parseInt(value);
  29.         var workspaceData = getMapFile("Workspace", true);
  30.         workspaceData.setValue("Autosave Interval", gDuration);
  31.     }
  32. }
  33.  
  34. function OnStartupTask()
  35. {
  36.     gAutoSave = getMapFileValue("Preferences", "Auto save files", true);
  37.     if (gAutoSave)
  38.     {
  39.         var logEvents = getGlobal("LogEvents", false);
  40.         if (logEvents)
  41.         {
  42.             gOutput.writeLine("Starting Autosave Task");
  43.         }
  44.         
  45.         gDuration = getMapFileValue("Workspace", "Autosave Interval", gDuration); 
  46.         Application.schedule("DoTask", gDuration, null, getScriptPath()); 
  47.     }
  48. }
  49.  
  50. function DoTask()
  51. {
  52.     gAutoSave = getMapFileValue("Preferences", "Auto save files", true);
  53.     if (gAutoSave)
  54.     {
  55.         
  56.         Application.autoSave(); 
  57.         
  58.         //Schedule again
  59.         Application.schedule("DoTask", gDuration, null, getScriptPath()); 
  60.     }
  61. }
  62.  
  63. !!/Script
  64.  
  65.