Re: Returning applescript results from Cocoa
Re: Returning applescript results from Cocoa
- Subject: Re: Returning applescript results from Cocoa
- From: matt neuburg <email@hidden>
- Date: Tue, 14 Jan 2003 11:19:54 -0800
On Mon, 13 Jan 2003 14:06:14 -0600, "Josh Ferguson" <email@hidden> said:
>
I wasn't sure if this was the appropriate list for this,
>
but since it has to do with the coding side of things, I
>
figured it wasn't totally off-topic. The application I'm
>
working on (FileStorm) is 100% AppleScript-able. I know
>
in AppleScript that you can wait for a specific apple
>
event to be returned from the application that you're
>
scripting. My question is how would I send an apple event
>
from my application signifying that a specific command has
>
completed (i.e. when a build has completed)? Does anyone
>
have any recommended reading on this subject? I've
>
browsed most of Apple's AppleScript documentation, but
>
can't find a whole lot in regards to Apple Events in Cocoa.
Actually, I've never heard of that ("you can wait for..."). Typically what happens is that the caller will just wait for a reply, not because it wants to but because it has to. So if an Apple event comes in asking you to do something time-consuming, and you want the caller to know when you've done it, then one simple solution is not to reply until you've done it. The caller will typically block until the reply comes back. To see this in action, play the caller's role - send an Apple event to the Finder asking it to duplicate a huge folder. The Finder isn't doing anything special here, it just isn't replying until it's done. Apple events let you set a timeout, so it's important, for long processes of this sort, to specify a very long timeout, or the caller will get the timeout response from the system before the reply has a chance to come back.
Now, there is another common architecture where you use Apple events like notifications. For example, Eudora lets you send it an Apple event that registers your app as a "helper" app to be notified when mail arrives. Now your app doesn't block because it isn't waiting for anything. If mail arrives, you get an Apple event from Eudora, but it has initiated this conversation, not you. It's the difference between whether what comes to your app is the reply to an Apple event you initiated or an Apple event initated by another app. m.
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.