-- I put this in the stack script of the main stack that is getting compiled into a Mac application on appleEvent theClass,theID
global thisStackName
if theClass is "misc" and theID is "dosc" then
request appleEvent data -- get the content of the AppleEvent
put it into thedata


-- hard code the card ID and stack name that you want to be on.
-- sometimes the appleevent handler is on this card, sometimes not, this
-- insures that where ever it is, it comes back to where it should be.
put "myAppleEventAcceptingApplication" into theStackName
put "1267" into theCardId
if the name of this stack is theStackName AND /
the id of this card = theCardId then
go to card id theCardId of stack theStackName
end if


-- now that we know we are on the correct card, I can take the data, put it into a field
put thedata into field "theData"
-- and then press a button that will manipulate the data in that field, and the button will
-- put the results into another field
send doit to button "actionButton"


    -- grab the results from that field
    put field "theResult" into theResult

-- this sends the results data back to the application that sent the appleEvent.
reply theResult
else
-- there are plenty of appleEvents that get sent to an application and
-- if it is not the misc dosc combination, then pass it on so that it
-- gets dealt with in the normal manner by Revolution.
pass appleEvent
end if
end appleEvent


-----------------------------------------------
I am sending data from HyperCard to this app using AppleEvents and having that data manipulated and then the results returned back to Hypercard. The AppleScript I am using in Hypercard is:


property thedata : []
property theresult : []

on mouseUp
        doit()
end mouseUp

to doit()
        copy field "thedata" as text to thedata
        copy "" to field "theresult"
        
        try
                tell application "myAppleEventAcceptingApplication"
                        activate
                        with timeout of 1200 seconds
                                -- do script is appleevent of "dosc"
                                do script thedata
                        end timeout
                        copy the result to theresult
                end tell
                copy theresult to field "theresult"
        on error errMsg number errNum
                copy "" & return & "" & return to theresult
                copy theresult to field "theresult"
        end try
        
        tell application "HyperCard"
                activate
        end tell
end doit

_______________________________________________
use-revolution mailing list
[email protected]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to