On Feb 12, 2005, at 9:17 AM, Irwin Poche wrote:
There has to be a simple solution to this but it eludes me.
It appears that applications can't deal with simple condition handlers. This example issues an Applescript Error "TextEdit got an error: Can't continue simplicity." Same result for iPhoto 5.0.1 and iTunes...
tell application "TextEdit"
activate
simplicity("testing")
end tell
on simplicity(xxx)
display dialog xxx
end simplicity
but this works...
simplicity("testing")
on simplicity(xxx)
display dialog xxx
end simplicity
The first example will work by using a tell me to before simplicity but that seems unnecessary and kludgy.
Please see the AppleScript Language Reference Guide, page 284, "Subroutines."
If you need to call a subroutine from within a Tell statement, you must use the
reserved words of me or my to indicate that the subroutine is part of the script
(not a command that should be sent to the object of the Tell statement).
For example, the minimumValue subroutine call in the following Tell statement is
unsuccessful, even if the script contains the minimumValue routine defined in “A
Sample Subroutine” (page 282), because AppleScript sends the minimumValue
command to AppleWorks. If you run this script, you get an error message
saying that AppleWorks does not understand the minimumValue message.
tell front document of application "AppleWorks"
minimumValue(12, 400)
copy result as string to word 10 of text body
end tell --result: An error, because AppleWorks doesn’t
-- understand the minimumValue message.
If you use the words of me in the subroutine call, as shown in the following Tell statement, the subroutine call is successful, because AppleScript knows that the
subroutine is part of the script.
tell front document of application "AppleWorks"
minimumValue(12, 400) of me
copy result as string to word 10 of text body
end tell
--result: The subroutine call is successful.
You can use the word my before the subroutine call as a synonym for the words
of me after the subroutine call. For example, the following two subroutine calls
are equivalent:
minimumValue(12, 400) of me
my minimumValue(12, 400)
Chris