Pesky -1708 error

I’ve got a script designed to run in Messages when a particular buddy logs in or out. It writes the information to a Pages file.

It runs without error in Script Debugger; it runs without error if run from a Mail rule. But if I set it to run in Messages if a buddy becomes available (or unavailable), it returns the pesky -1708 error. (it does what it’s supposed to, so the only issue is that Messages waves at me from the Dock and the dialog box has to be dismissed.)

[I included code trying to trap the error, but that code never runs.]

The script is below. Any suggestions how to eliminate it gratefully appreciated.


set theDate to (current date)
set cr to ASCII character 13
tell application “Pages”
open “/Users/lofty/Library/Mobile Documents/com~apple~Pages/Documents/Buddies.pages-tef”
set (text of document 1) to "Office logged in " & theDate & cr & (text of document 1) as text
end tell
on error -1708
display dialog “oops”

end try

Model: iMac
Browser: Safari 536.25
Operating System: Mac OS X (10.8)


does Pages really consider POSIX paths?
Usually the most reliable way is using file [HFSpath].

Another cause could be to get and set the text property in one line without an explicit get
and the save command without a document target.

The display dialog is never been called because you want to check for the error number but actually check for the error text (it could be that the event handler doesn’t support user interaction at all)

Try this

	set theDate to (current date)
	set buddiesFilePath to ((path to library folder from user domain as text) & "Mobile Documents/com~apple~Pages/Documents/Buddies.pages-tef")
	tell application "Pages"
		open file buddiesFilePath
		tell document 1
			set its text to "Office logged in " & theDate & return & (get its text)
		end tell
	end tell
on error number -1708
	display dialog "oops"
end try

If you don’t need any formatted text a log file can be realized easier (and more unobtrusive) with AppleScript’s read/write commands


Thanks for the suggestion (and for much cleaner code :)). Oddly, the path function returns colons not slashes as folder separators, so I had to change my part to colons, but otherwise it works fine from the editor and is, as I said, better code than mine. I’ll have to wait until I log in on my office machine to see if the changes make a difference when the script runs in Messages.

You’re right, of course, that just writing to a log file is probably easier. If the experiment goes on and I can find the time I’ll learn the file creation/open/write commands in AppleScript.

Thanks again.


Colon separated paths (HFS) is the designated path style in AppleScript


You were of course absolutely right ” I acquainted myself, apparently adequately, with the file opening and writing commands, rewrote the scripts, and they seem to work beautifully in test mode. :slight_smile: A lot faster, too. So far nothing has triggered them, but I expect they’ll work equally well when run from Messages.

Again, very many thanks.


Sigh. There must be something about running scripts in Messages.

Even the new script produces a -1708 error when it runs:

set TheFilePath to ((path to desktop from user domain as text)) & “Buddies Log File.txt”
– set the text to write
set textToWrite to "Office logged in " & (current date) & return
– open the file
set theFile to (open for access file TheFilePath with write permission)
– write text to it
write textToWrite to theFile starting at eof
– close the file
close access theFile

Maybe I just have to live with it.:frowning: But at least the new version is cleaner and faster.