Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Slight improvement' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Slight improvement
Authored by: TheWayOfTheGun on Apr 21, '05 05:52:29AM
Thanks for the tip. I'm installing that as a cron job. I did make two changes. First, I removed the activate call so that iSync can run in the background. Then, I noticed that the loop waiting for sync to finish is bound to burn a lot of CPU cycles. Here is a slight tweak that is a tad more efficient:

tell application "iSync"
end tell

on idle
	tell application "iSync"
		set syncStatus to sync status
		-- syncStatus = 2 -> successfully completed sync
		if syncStatus = 1 then
			return 7
		else if syncStatus = 2 then
			tell me to quit
			if syncStatus = 3 then
				set syncStatus to "completed with warnings"
			else if syncStatus = 4 then
				set syncStatus to "completed with errors"
			else if syncStatus = 5 then
				set syncStatus to "last sync cancelled"
			else if syncStatus = 6 then
				set syncStatus to "last sync failed to complete"
			else if syncStatus = 7 then
				set syncStatus to "never synced"
			end if
			display dialog "syncStatus: " & syncStatus
		end if
	end tell
end idle
To get this to work, you'll need to save as Application and check the "Stay Open" box. After the initial tell block, the idle block is called every few seconds. Once sync is done, the script tells iSync to quit and then quits itself.

[ Reply to This | # ]