• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problems with scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with scripting


  • Subject: Re: problems with scripting
  • From: Vitaly Ovchinnikov <email@hidden>
  • Date: Fri, 12 Jun 2009 22:21:03 +0400

Hello Matt,

I finally did something using the following suite definition:
<suite name="My Suite" code="mysu">
	<class name="document" code="docu" description="my project"
plural="document" inherits="document">
		<cocoa class="MyDocument"/>
		<property name="source" code="snam" description="name of source
file" type="text">
			<cocoa key="sourceFile"/>
		</property>
		<responds-to command="dosomething">
			<cocoa method="handleDoSomethingScriptCommand:"/>
		</responds-to>
	</class>
	<command name="dosomething" code="dosc" description="do something">
		<cocoa class="NSScriptCommand"/>
		<direct-parameter type="document"/>
		<result type="any"/>
	</command>
</suite>

MyDocument is derived from NSDocument and has property sourceFile and method
- (id) handleDoSomethingScriptCommand: (NSScriptCommand *) cmd
{NSLog(@"got it"); return nil; }

I wrote a simple script:
tell application "My App"
	activate
	make new document
	set source of first document to "/some/path/here"
	--tell first document to dosomething
	close first document
end tell

This works until I remove comments from the line that calls my method.
I receive an error that there is no variable "dosomething".
I tried another syntax: "dosomething first document" and received an error too.

The questions:
1. Did I correctly subclassed document from standard suite?
2. Did I correctly described a property? Should it be string or file
type if it is a path?
3. What did I do wrong with calling of method? How to fix it?

Thank you.

On Fri, Jun 12, 2009 at 7:48 PM, Matt Neuburg<email@hidden> wrote:
> On Fri, 12 Jun 2009 14:45:48 +0400, Vitaly Ovchinnikov
> <email@hidden> said:
>>Hello,
>>
>>I completely stumped with allowing my application to be called from
>>apple-script. After reading of apple docs, I added simple sdef file
>>and two keys to info.plist. Sdef file contains only standard suite and
>>nothing added by me, but even with this I can't run the simplest
>>script like this one:
>>
>>tell application "MyApp"
>>    get name of document 1
>>end tell
>
> Does your sdef define the document class, and does it link it to the Cocoa
> class of your NSDocument subclass and specify the "name" element as 'pnam'?
> m.
>
> --
> matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
> A fool + a tool + an autorelease pool = cool!
> AppleScript: the Definitive Guide - Second Edition!
> http://www.tidbits.com/matt/default.html#applescriptthings
>
>
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: problems with scripting
      • From: Matt Neuburg <email@hidden>
References: 
 >Re: problems with scripting (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: How can we mount and unmount dmg files on MAC OS X?
  • Next by Date: Re: Missing something about initialization
  • Previous by thread: Re: problems with scripting
  • Next by thread: Re: problems with scripting
  • Index(es):
    • Date
    • Thread