Example 4: Run CloudSync
The following example runs CloudSync, but not more than once every 12 hours.
To execute this Script after an AutoWatch check run, insert the following Script into the special Script autowatch_after.wws (Main menu + Script + Edit special scripts + autowatch_after.wws).
//Run CloudSync every 12 hours
//Load last sync date
$Date = FileToString("c:\myfiles\CloudSync.dat")
//Calc difference in hours
$Diff = HoursAgo($Date)
if $Diff < 12 then goto End
CloudSync
//Save last sync date
$Now = Now
StringToFile("c:\myfiles\CloudSync.dat", $Now)
label End
To run CloudSync only when the database "sync.wsw" is loaded, you can extend the Script as follows:
//Run CloudSync every 12 hours (only if database sync.wsw is opened)
$DB = GetBookmarkFilename
$DB = Lowercase($DB)
if $DB <> "sync.wsw" then goto End
//Load last sync date
$Date = FileToString("c:\myfiles\CloudSync.dat")
//Calc difference in hours
$Diff = HoursAgo($Date)
if $Diff < 12 then goto End
CloudSync
//Save last sync date
$Now = Now
StringToFile("c:\myfiles\CloudSync.dat", $Now)
label End