Re: AppleScript Support in Cocoa/Java
Re: AppleScript Support in Cocoa/Java
- Subject: Re: AppleScript Support in Cocoa/Java
- From: Don Briggs <email@hidden>
- Date: Mon, 17 Nov 2003 08:50:37 -0800
Hi, Moray
[1] You might try deleting the class NSApplication from the suite.
It declares (redundantly) ordered documents, but not ordered windows.
[2] Try changing all your commands' class codes (DEMO, DISC. OPCO) to
the suite's code, DATP.
That's the default in Suite Modeler, but it doesn't flag deviations as
errors.
[3] You have some other Apple Event Code assignments that seem
trouble-prone.
code ext. name type
pnam URL NSObject pnam generally associates with "name" and
NSString
opco open con... OpenConnection all
lower-case* disc Disconnect Disconnect all lower-case*
*Apple reserves the space of all-lower-case codes. However, we can
re-use them. Your 'capp' and 'docu' codes
seem fine in that regard. I haven't seen documentation from Apple that
clarifies this, though.
See
/Developer/SDKs/MacOSX10.3.0.sdk/Developer/Headers/FlatCarbon/
AERegistry.h
for codes we're to re-use.
There, we find
>
/* Classes */
>
cURL = 'url ',
That may prove useful in your OpenConnection command's URL argument.
(Can't tell -- it' type is NSObject.)
[4] All of your command handlers are
handleDemonstrateScriptCommand:
Put a break point in the handler.
I expect that your DoSQL and Disconnect commands BOTH invoke the
handler (fine from the outside -- they both have no arguments.)
However, OpenConnection has an argument.
>
<key>SupportedCommands</key>
>
<dict>
>
<key>Disconnect</key>
>
<string>handleDemonstrateScriptCommand:</string>
>
<key>DoSQL</key>
>
<string>handleDemonstrateScriptCommand:</string>
>
<key>OpenConnection</key>
>
<string>handleDemonstrateScriptCommand:</string>
>
</dict>
For my own information,
[5] I'm surprised that the Java command handlers have Objective-C-like
colons
handleDemonstrateScriptCommand:
I just checked the Java Sketch example, and its suite has no supported
commands.
I've not fooled with scripting Cocoa/Java.
Regards,
Don
On Nov 17, 2003, at 2:10 AM, Moray Taylor wrote:
>
Hi,
>
>
I am trying to implement AppleScript support in my Cocoa app, after
>
many, many hours of effort, I got my custom commands to work, woohoo!
>
However, I can only get simple, no argument commands to work, any with
>
an argument I get this error
>
>
NSCannotCreateScriptCommandError
>
>
>
I have copied and pasted my scriptsuite and terminology files below,
>
Disconnect, and DoSQL work, openconnection gives me the error.
>
>
I am quite experienced with AppleScript, so I don't think my script is
>
the problem
>
>
I don't see why simple arguments could cause me such a problem, I'm
>
sure it must be something simple, any ideas?
>
>
Many thanks in advance.
>
>
Moray
>
>
>
tell app "Lynx"
>
tell front document
>
do SQL -- works
>
disconnect -- works
>
open connection "whatever" -- gives error
>
end tell
>
end tell
>
>
>
This is my scripSuite
>
>
<?xml version="1.0" encoding="UTF-8"?>
>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
>
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
>
<plist version="1.0">
>
<dict>
>
<key>AppleEventCode</key>
>
<string>DATP</string>
>
<key>Classes</key>
>
<dict>
>
<key>MyDocument</key>
>
<dict>
>
<key>AppleEventCode</key>
>
<string>docu</string>
>
<key>Superclass</key>
>
<string>NSCoreSuite.NSDocument</string>
>
<key>SupportedCommands</key>
>
<dict>
>
<key>Disconnect</key>
>
<string>handleDemonstrateScriptCommand:</string>
>
<key>DoSQL</key>
>
<string>handleDemonstrateScriptCommand:</string>
>
<key>OpenConnection</key>
>
<string>handleDemonstrateScriptCommand:</string>
>
</dict>
>
</dict>
>
<key>NSApplication</key>
>
<dict>
>
<key>AppleEventCode</key>
>
<string>capp</string>
>
<key>Attributes</key>
>
<dict/>
>
<key>Superclass</key>
>
<string>NSCoreSuite.NSApplication</string>
>
<key>ToManyRelationships</key>
>
<dict>
>
<key>orderedDocuments</key>
>
<dict>
>
<key>AppleEventCode</key>
>
<string>docu</string>
>
<key>Type</key>
>
<string>MyDocument</string>
>
</dict>
>
</dict>
>
</dict>
>
</dict>
>
<key>Commands</key>
>
<dict>
>
<key>Disconnect</key>
>
<dict>
>
<key>AppleEventClassCode</key>
>
<string>DISC</string>
>
<key>AppleEventCode</key>
>
<string>disc</string>
>
<key>CommandClass</key>
>
<string>NSScriptCommand</string>
>
</dict>
>
<key>DoSQL</key>
>
<dict>
>
<key>AppleEventClassCode</key>
>
<string>DEMO</string>
>
<key>AppleEventCode</key>
>
<string>Demo</string>
>
<key>CommandClass</key>
>
<string>NSScriptCommand</string>
>
</dict>
>
<key>OpenConnection</key>
>
<dict>
>
<key>AppleEventClassCode</key>
>
<string>OPCO</string>
>
<key>AppleEventCode</key>
>
<string>opco</string>
>
<key>Arguments</key>
>
<dict>
>
<key>URL</key>
>
<dict>
>
<key>AppleEventCode</key>
>
<string>pnam</string>
>
<key>Type</key>
>
<string>NSObject</string>
>
</dict>
>
</dict>
>
<key>CommandClass</key>
>
<string>NSScriptCommand</string>
>
</dict>
>
</dict>
>
<key>Name</key>
>
<string>Lynx</string>
>
</dict>
>
</plist>
>
>
>
My terminolgy suite
>
>
>
<?xml version="1.0" encoding="UTF-8"?>
>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
>
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
>
<plist version="1.0">
>
<dict>
>
<key>Classes</key>
>
<dict>
>
<key>Lynx</key>
>
<dict>
>
<key>Attributes</key>
>
<dict/>
>
<key>Description</key>
>
<string>Lynx</string>
>
<key>Name</key>
>
<string>Lynx</string>
>
<key>PluralName</key>
>
<string>demo apps</string>
>
</dict>
>
</dict>
>
<key>Commands</key>
>
<dict>
>
<key>Disconnect</key>
>
<dict>
>
<key>Description</key>
>
<string>Disconnects from the current database.</string>
>
<key>Name</key>
>
<string>Disconnect</string>
>
</dict>
>
<key>DoSQL</key>
>
<dict>
>
<key>Arguments</key>
>
<dict/>
>
<key>Description</key>
>
<string>Demonstrates an AppleScript command handler in
>
Cocoa.</string>
>
<key>Name</key>
>
<string>do SQL</string>
>
</dict>
>
<key>OpenConnection</key>
>
<dict>
>
<key>Arguments</key>
>
<dict>
>
<key>URL</key>
>
<dict>
>
<key>Description</key>
>
<string>The database to connect to.</string>
>
<key>Name</key>
>
<string>URL</string>
>
</dict>
>
</dict>
>
<key>Description</key>
>
<string>Open a connection</string>
>
<key>Name</key>
>
<string>open connection</string>
>
</dict>
>
</dict>
>
<key>Description</key>
>
<string></string>
>
<key>Name</key>
>
<string>Lynx Suite</string>
>
</dict>
>
</plist>
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.