AppleScript: call handler inside tell statement

I get this error every time I run this script: system events received an error message: "Test123" does not understand the notification message.

the code:

--more code...
tell application "System Events"
    if some_system_events_property then
         my notify of "Test123" thru "Test"
    end if
end tell
--more code...
to notify of message thru level
    display dialog message with titel level
end notify

I tried to replace

my notify of "Test123" thru "Test"

with the following, without any success:

notify of "Test123" thru "Test" of me
(notify of "Test123" thru "Test") of me
+5
source share
2 answers

Try the following:

tell application "System Events"
    if some_system_events_property then
        tell me to notify of "Test123" thru "Test"
    end if
end tell

to notify of message thru level
    display dialog message with title level
end notify

Although I will also say that I never use direct parameter syntax for AppleScript handlers, preferring positional parameters (i.e. notify( message, level )), as it avoids the ambiguous syntax problems that you find.

+3
source

, , ,

tell application "System Events"
    set m to "message content"
    my notify(m)
end tell
--more code...
on notify(message)
    display dialog (message)
end notify
+3

All Articles