Having RunRev Standalone accept and reply to AppleEvents?

kee nethery kee at kagi.com
Tue Jan 25 20:32:45 EST 2005


I have a one card stack in RunRev that gets saved as an application, 
and is used to catch, process and reply to AppleEvents. It is supposed 
to be controllable via AppleEvents. I've gone through over 20 
iterations to try to duplicate some existing functionality in an 
existing Hypercard stack/standalone application. I scanned all the 
example stacks and RunRev docs I could find that mention AppleScript. 
Nothing talks about these issues.

I can get the standalone app to reply to the first appleevent but then 
after that it is deaf.
But, if I uncomment the two "answer" lines, this application will reply 
to all the appleevents sent to it.

Second weirdness is that the on appleEvent takes the script to a 
library stack and for this to work at all, I have to actively go back 
to the one single card in my standalone application, interact with the 
buttons and fields, and then go back to whatever stack I got diverted 
to when processing the appleEvent. To my mind that is completely weird 
behavior. But if I do not do it, this stack doesn't even work the first 
time.

Oh yes, the docs say that "on appleEvent" can be in a card script but 
doing that causes it to not catch a "misc" class wth a "dosc" ID 
appleevent.


Here's the stack script:


on preOpenStack
   -- I put the name of the standalone into a global so that I can get 
back to this standalone stack
   -- when processing an AppleEvent to do the tasks.
   global thisStackName
   start using "revSOAP"
   put the name of this stack into thisStackName
end preOpenStack

on appleEvent theClass,theID -- execute a set of statements
   global thisStackName
   -- When I uncomment this answer line, and the other one below, it 
works more than once
   -- answer theClass && theID
   if theClass is "misc" and theID is "dosc" then
     request appleEvent data -- get the content of the AppleEvent
     put it into thedata
     -- the other answer line that gets uncommented
     -- answer thedata with "thedata"

     push card
     -- OK this is strange. I'm in this stack script but in actual fact, 
I'm in some runrev library when
     -- I'm at this point in the script and unless I actively go back to 
the stack where this script
     -- is located, I cannot interact with the fields or buttons of this 
standalone. So this
     -- push and pop moves me back to where I would normally think I was.
     go to stack thisStackName

     -- this line executes the first time through and then after that, 
thedata never makes it into the field
     -- uncomment the "answer" lines and this line executes as do the 
remaining lines
     put thedata into field "theSQL"

     -- doSQL takes the SQL and sends it to the database and then puts 
the results into the soapResult field
     send doSQL to button "execute SQL"

     put field "soapResult" into theResult

     -- Since I'm in this stack, and for some reason RunRev wants me to 
be in another stack, I pop back
     -- to the library where I am supposed to be. That's the theory at 
least.
     pop card

     -- I format the text for a Mac.
     replace return with numtochar(13) in theResult

     -- this sends the data back to the application that sent the 
appleEvent.
     reply theResult
   else
     -- it is my understanding that if I do not "reply" then I must 
"pass AppleEvent"
     -- it is also my understanding that if I do "reply" I do not "pass 
appleEvent"
     pass appleEvent
   end if
end appleEvent

So why is this not working? Any ideas?
Thanks in advance.
Kee Nethery



More information about the use-livecode mailing list