Help with AppleEvents
Rob Cozens
rcozens at pon.net
Sat Nov 15 08:47:21 EST 2003
>If this is true, I am screwed!
Does this help, Paul?
>Message: 5
>Date: Sun, 16 Mar 2003 04:39:41 -0800 (PST)
>From: Jan Schenkel <janschenkel at yahoo.com>
>Subject: Re: Does Send To Program Work?
>To: use-revolution at lists.runrev.com
>Cc: improve-revolution at lists.runrev.com
>Reply-To: improve-revolution at lists.runrev.com
>
>--- Rob Cozens <rcozens at pon.net> wrote:
>> Hi All,
>>
>> I'd like to hear from one person who can confirm
>> that "send .. to
>> program" works.
>>
>> Scenario:
>>
>> I start a RunRev standalone, "IPC_Server".
>>
>> I start RunRev on the same computer.
>>
>> From the message box I type 'send "Quit" to program
>> "IPC_Server"'
>> result: no such program
>>
>> I launch clip2Gif and type 'send "Quit" to program
>> "clip2Gif"'
>> result: no such program
>>
>> Again from the message box, 'send "Quit" to program
>> "Finder"'
>> result: got error -1702 when sending apple event
>> [1702 = invald data]
>>
>> Mac OS 9, RR v1.5A7
>> --
>>
>> Rob Cozens
>
>Hi Rob,
>
>It took me a while to test various combinations, but
>here are my conclusions for RunRev 1.1.1:
>
>1) 'send to program ... with reply'
>- problem: results in an error upon execution
>- solution: omit the optional 'with result' clause
>- note: 'without reply' doesn't result in an error
>
>2) 'answer program' doesn't work in MC/RR
>- known issue, due to limitations in the Carbon API
>- solution: do "choose application" as AppleScript
>- note: would still be handy if it were included
>
>2) 'send to program' on the same machine works, but
>'send to program' where the program is on a remote
>machine doesn't work
>- i tried it on a variation of machines, but the error
>is always "no such program"
>- solution: AppleScript to the rescue ! there is a
>little-known method of sending 'raw' apple events from
>within AppleScript, so the trick is to wrap it as an
>AppleScript of the form:
> tell application "Foo" of machine "Bar"
> <<event rIPCrIPL>> "Hello there!" & return
> end tell
>in which << and >> are to be replacd by their
>single-char equivalents for MacOS (ASCII- 199 and
>200).
>So here's a sample code that works :
> on SelectProgramAndSendAE pAEclass, pAEid, pAEdata
> do "choose application" as AppleScript
> put the result into tResult
> if tResult is "execution error" then
> return "Cancel"
> else put tResult into tProgram
> -- looks like: application "Foo" of machine "Bar"
> put "tell" && tProgram & return into tAScript
> put numToChar(199) & "event" && pAEclass & pAEid \
> & numToChar(200) && pAEdata && "& return" & \
> return after tAScript
> put "end tell" & return after tAScript
> do tAScript as AppleScript
> return the result
> end SelectProgramAndSendAE
>- note: this was very messy to debug, and I crashed my
>iBook several times before I got it right.
>- warning: if the application on the other side is a
>RunRev-built one, make sure you 'pass' any AppleEvent
>message that you don't handle with a 'reply', or you
>risk freezing up the client-side computer.
>
>I also tested the same code with pre-beta 4, with
>equal results. So in conclusion: yes, this is a
>definite bug, and I don't like the workaround, but at
>least there is one.
>
>Scott or Kevin, could this be fixed for MetaCard 2.5 /
>RunRev 2.0?
>
>Jan Schenkel.
--
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.net/who.htm
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list