Quote:
Originally Posted by tbreyman
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