Reputation: 7350
I have a property of my application in my sdef dictionary called busy
<property name="busy" code="mybs" type="boolean" access="r" description="Is application busy?">
<cocoa key="isBusy"/>
</property>
Also I have NSApplication category with isBusy
accessor
- (BOOL)isBusy
{
return NO;
}
The scripts
tell application "MyApplication"
properties
end tell
and
tell application "MyApplication"
busy
end tell
work fine and busy
property is false, but script
busy of application "MyApplication"
returns error
error "MyApplication got an error: Can’t make |busy| into type specifier." number -1700 from |busy| to specifier
Where is my mistake?
Upvotes: 3
Views: 401
Reputation: 18703
Since busy
is a term specific to your application, it must be preceded by tell
or using terms from
to make the term known at that point in the code. Any of these will work:
tell application "MyApplication" to busy
tell application "MyApplication"
busy
end tell
using terms from application "MyApplication"
busy of application "MyApplication"
end using terms from
AppleScript parses left-to-right and has to know what the valid terms are before it can parse them. It doesn’t skip to the end of busy of application "MyApplication"
to figure out how to parse the start of the expression. If MyApplication had a term busy of
it would completely change the meaning of that expression and cause a paradox: of
would no longer be the keyword used to construct object specifiers, which means it wouldn’t get terminology from MyApplication, which means it would be the of
keyword and it would get the terminology from the application…ad infinitum.
You may be wondering why some application properties, like name
, version
and running
work without introducing the application’s terminology. They work because they’re defined by the global system terminology and are not specific to your application.
Note that the 's
possessive operator does not introduce terminology like tell
does, so this doesn’t work, either (unless you precede it with a tell
or using terms from
):
application "MyApplication"'s busy
Upvotes: 1
Reputation: 4894
This will not work because it is an illegal Apple Script sentence.
The get
command, which was suggested by regulus6633, will prepended automatically if you omit it (See Events tab in Apple Script Editor). And each command needs a performer to execute it. The implied get
command has in your broken sentence no container which is necessary to build a specifier like "blah of blah of blah"t
Upvotes: 0