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

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