"NSReceiverEvaluationScriptError: 4" in iCal&AddressBook backup script

“NSReceiverEvaluationScriptError: 4” in iCal&AddressBook backup script

Hi all,
I got this great looking script to make versioned backups of iCal and Address Book from here: http://blog.socklabs.com/2006/03/22/ical_backup_applescript/
(full script pasted below)

However, when I try to run it I’m getting an error: “NSReceiverEvaluationScriptError: 4”
The error seems to be occuring at this line:

tell menu item "Back up Database..." of menu "File" of menu bar 1 of application process "iCal" to click

I’m running the script from Script Editor and when the error happens, the word “click” is hi-lighted on the above line.

I tried swapping the order to have the Adress Book go first and get the same result on the analogous Address Book line.

This error happens regardless of whether iCal was already running before the script runs.
Yes, I have GUI scripting enabled.
I tried using the app UI Browser to take a look in iCal and see if maybe the menu item wasn’t being referred to correctly. Based on what I saw in UI Browser, I tried the following line of code instead:

tell menu item "Back up Database..." of menu 1 of menu bar item "File" of menu bar 1 of application process "iCal" to click

But that had the same error result.

I thought maybe one of the Unsanity haxies I had installed (FruitMenu, MenuMaster, and WindowShades) was somehow messing with the menus, so I temporarily turned them all off using the Application Enhancer control panel in system prefs. But I still got the same error when I logged back in with the haxies disabled.

Man, I thought this was going to be easy! Anyone have any suggestions?
thanks very much,
~jason


-- Get system date and convert it to mm--dd--yy format --
set todaysDate to (current date)
set {d, m, y} to {day, month, year} of todaysDate

set yearString to text -2 thru -1 of ("0" & (y mod 100))

set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
	if m = (item i of monthList) then
		set monthString to text -2 thru -1 of ("0" & i)
		exit repeat
	end if
end repeat

set todaysDate to " - " & monthString & "/" & d & "/" & yearString

set l_backupfolder to "Backup"

tell application "Finder"
	activate
	select window of desktop
	if not (folder (l_backupfolder) exists) then
		make new folder at desktop with properties {name:l_backupfolder}
	else
		display dialog "You seem to have already backed up today. Backing up again may overwrite some files. Continue anyways?" buttons {"Cancel", "OK"} default button 2
	end if
end tell

tell application "iCal" to activate
tell application "System Events"
	tell menu item "Back up Database..." of menu "File" of menu bar 1 of application process "iCal" to click
	delay 3
	keystroke "iCal" & todaysDate
	keystroke "d" using command down
	delay 3
	keystroke tab
	keystroke return
	delay 5
end tell

tell application "Address Book" to activate

tell application "System Events"
	tell menu item "Back up Address Book..." of menu "File" of menu bar 1 of application process "Address Book" to click
	delay 1
	keystroke "Address Book" & todaysDate
	keystroke "d" using command down
	delay 1
	keystroke tab
	keystroke return
	delay 5
end tell


tell application "Finder"
	activate
	move file ("iCal" & todaysDate & ".icbu") in desktop to folder l_backupfolder in desktop
	move file ("Address Book" & todaysDate) in desktop to folder l_backupfolder in desktop
end tell

do shell script "cd ~/Desktop"
do shell script "tar zcvf ~/Desktop/backup.tgz ~/Desktop/" & l_backupfolder
do shell script "scp ~/Desktop/backup.tgz user@host:~/backups/"
do shell script "rm -rfv ~/Desktop/backup.tgz"

Model: G5 dual 2.3ghz
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi, UniAce.

In this line, do you have three full stops after “Database” or an ellipsis character? (Option-; on English keyboards.) Menu items of this type normally have an ellipsis rather than three individual dots.

You guys are the greatest. That was it. Jacques, I couldn’t see what was different about the line you suggested, but when Nigel spelled it out I understood. I had three periods where an ellipsis was called for. I think when I copied the script text from the source, some weird encoding snafu happened because I remember some weird O-looking character with an accent over it that I had to replace with the three periods.
It’s working now. Yes!!