[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Catching the event which launched a runtime app?



Having had some success using MacPerl to drive other applications via
AppleEvents I thought it now time to try it the other way around...

Specifically I'm attempting to build a MacPerl runtime/standalone
application that receives events. Here's a quick sample:

use Mac::AppleEvents;

$AppleEvent{"ECpl", "link"} = "ScriptRunnerLink";

while (!$ok) {
    sleep(1);
    }

sub ScriptRunnerLink {
    my($event, $reply) = @_;
    print "Script Runner sent us a link.\n";
    AEPutParam($reply, "----", "TEXT", "You told us to link.");
    
    # Eval out.
    0;
}


Note that what I'm actually trying to do is have the ScriptRunner PostLinker
for CodeWarrior (http://www.elegantchaos.com/software/runner.html) call a
MacPerl app instead of a compiled AppleScript. However, my issue happens
regardless of whether I use ScriptRunner or a simple test AppleScript to
send the ECpllink event:

tell application "AEventtest.run"
    «event ECpllink»
end tell

My problem appears to be that while sending the ECpllink event as the first
event to the app, the app launches but my code is never reached. MacPerl
returns an error immediately. Once my script has had time to install its
hooks, however, things work just fine.

Is there some way to prevent MacPerl from replying before I get a chance?

Thanks for any suggestions,

Alex


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org