View Single Post
whpalmer4 has alerted me to the fact that at least one of my scripts, which used to work fine, has started to trip an error message where current date falls somewhere within tell front document ... end tell

And the bug is a subtle one - one of the following sequences trips an error, but the other doesn't ...

ERROR:
Code:
-- WORKS IF RUN AFTER THE OTHER TWO, 
-- BUT FAILS IF RUN BEFORE THEM, OR IN A SCRIPT ON ITS OWN
tell application "OmniFocus"
	tell front document
		current date
	end tell
end tell

-- WORKS
tell application "OmniFocus"
	set oDoc to front document
	tell oDoc
		current date
	end tell
end tell

-- WORKS
tell application "OmniFocus"
	tell default document
		current date
	end tell
end tell
NO ERROR:
Code:
-- WORKS
tell application "OmniFocus"
	set oDoc to front document
	tell oDoc
		current date
	end tell
end tell

-- WORKS
tell application "OmniFocus"
	tell default document
		current date
	end tell
end tell

-- WORKS IF RUN AFTER THE OTHER TWO, 
-- BUT FAILS IF RUN BEFORE THEM, OR IN A SCRIPT ON ITS OWN
tell application "OmniFocus"
	tell front document
		current date
	end tell
end tell

Last edited by RobTrew; 2011-09-10 at 02:07 AM..