The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Why don't date properties work in OmniFocus Thread Tools Search this Thread Display Modes
I've written a few scripts so far w/out too much trouble. I hit a snag today trying to retrieve the day property from a date.

When I enter the following script into the Applescript editor, everything works fine ...

Code:
	
set myDate to current date
return day of myDate
However, when I enter the following script, it doesn't even compile (I get an "Access not allowed." error ...

Code:
tell application "OmniFocus"
	
    set myDate to current date
    return day of myDate
	
end tell
What's going on? When I try to wrap the "day of myDate" logic in a subroutine, it compiles but I get a runtime error.

Thanks,

Todd
 
Quote:
Originally Posted by tbreyman View Post
What's going on? When I try to wrap the "day of myDate" logic in a subroutine, it compiles but I get a runtime error.
Wrapping it in a subroutine is no problem, but there are complexities of reference within the tell … end tell scope of an object.

The trick is just to retrieve your date outside the scope of the application object. The my prefix below, incidentally, is needed to specify the function as a method of the top level script, overriding the default assumption that you are calling a method of the object referenced by tell … end tell

Code:
on GetDay()
	return day of (current date)
end GetDay

set strDay to GetDay() as string

tell application "OmniFocus"
	display alert "One way: " & (my GetDay() as string)
	display alert "And other way: " & strDay
end tell
 
That did it. I tweaked your example to pass the date in. Now works like a charm.

Thanks
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textexpander doesn't work in date field ? Tado OmniFocus 1 for Mac 0 2012-05-19 04:32 AM
Properties/Geometry inspector doesn't work chriswinsatlife OmniGraffle General 0 2011-11-01 11:17 PM
Due date grouping in Omnifocus vs Omnifocus for iPhone arnthorsnaer OmniFocus 1 for Mac 3 2011-03-16 12:53 PM
Due date sorting Actions won't work? fire00 OmniFocus 1 for Mac 1 2010-01-22 01:33 PM
sequential project, due date don't work well together jeremydb OmniFocus 1 for Mac 9 2009-08-09 11:12 AM


All times are GMT -8. The time now is 05:58 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.