more iCal woes...

I have no clue why this isn’t working. Last week I pieced together a script to backup the iCal database, transfer to an external drive and email it out as well. The script ran fine, but the iCal alarm would not trigger the script. Someone suggested makeing it an app because iCal could not script itself. Fine. The app will still run fine. And on our tests creating one event it ran as well. Now, the repeating event, whcih is set to run everyday at 5 pm does not work. When I do a test event, I get the black and white spinning wheel (predecessor to the SBOD?). Even launching the app causes this. But running the script from script editor still makes it work flawlessly. Energy saver is off on the computer, “assistive devices” are on, and its running on an intel mini. Any help? Please??


-- Backup the iCal Database to an external drive on a daily basis.  Made with much help from numerous postings on the macscripter.net board.


set extDisk to "Renders"
set TodaysDate to short date string of (current date)
set theName to "XXXXXXXXX@gmail.com"
set theSubject to "iCal Back-up File for " & TodaysDate

--backup iCal database to desktop
try
	activate application "iCal"
	tell application "System Events"
		tell menu item "Back up Database." of menu "File" of menu bar 1 of application process "iCal" to click
		delay 2
		keystroke "iCal Backup - " & TodaysDate
		keystroke "d" using command down
		delay 2
		keystroke "s" using command down
	end tell
	
	--check for Backup Folder on external drive. If none exists, make one.
	tell application "Finder"
		set bFile to "iCal Backup - " & TodaysDate & ".icbu"
		if exists disk extDisk then
			if not (exists folder "iCal Backup" of disk extDisk) then make new folder at disk extDisk with properties {name:"iCal Backup"}
		end if
		repeat until (file bFile exists)
			delay 0.5
		end repeat
		
		
		move file bFile to folder "iCal Backup" of disk extDisk replacing yes
		-- delete file bFile
		delay 4
		delete file bFile of desktop
		
		
	end tell
end try

-- E-mail the backup file to Christian.  This script is partly based on Apple's provided "Create New Message" script.

set theAttachment to extDisk & ":iCal Backup:iCal Backup - " & TodaysDate & ".icbu" as alias

tell application "Mail"
	set TheMessage to make new outgoing message with properties {subject:theSubject, content:theSubject & return & return & return}
	tell TheMessage
		set visible to true
		make new to recipient at end of to recipients with properties {address:theName}
		tell content
			make new attachment with properties {file name:theAttachment} at after the last paragraph
		end tell
	end tell
	send TheMessage
end tell


Hi geddy

I don’t think ical like’s system events or GUI scripting these timed events.
Your script doesn’t have to be an application just do a display dialog in a script and save it as a script it works fine.
so does telling app ical to activate but bring system events into it and it errors.

try looking into launchd to run scripts at certain times also do a search for an app called lingon which will help you set it up.
try searching the forum and google…

hope this helps