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

Re: [MacPerl] MacPerl, AS, and GURL



At 19.21 -0600 2000.04.03, Keary Suska wrote:
>Thanks to Chris and Occam's Razor for the Outlook issue. Perhaps this one is
>a stumper for the AS grand master.
>
>I am trying to write a Perl program that is invoked by a web browser, email
>client, or whatever, as a special custom protocol handler. Assuming the
>simplest solution is the best (sorry, Occam) I set the proper parameters in
>the internet control panel and voila, nothing. I have the script as a
>runtime to make it distributable, but when invoked the script doesn't
>actually run. It simply opens and does nothing. From the best I can tell (I
>am no AS expert) an event class(?) "GURL" is being sent.

Yes.  You need to set a handler.  See the AEReceiver.t example for how to
handle the incoming event.  It would be something like this:

  #!perl -w
  use Mac::AppleEvents;
  use Mac::Events;
  $AppleEvent{'GURL', 'GURL'} = \&my_handler;

  my $ok = 0;
  sub my_handler {
      my($evt) = @_;
      my $url = AEGetParamDesc($evt, keyDirectObject);  # is it the D.O.?
      print $url->get, "\n";
      $ok = 1;
      0;
  }

  WaitNextEvent until $ok;


>My main question would be why is the program launching but the script not
>executing?

What is "the program"?  Your program, or MacPerl?


>Is there any way to get the MacPerl program to recognize the
>event without being already open? It seems as if I won't be able to execute
>the script to be able to install the handler in the first place.

I am not sure how that would work.  It may get the handler installed in
time, it may not.  You'd have to try and see.


>Is MacPerl
>a lost cause in this case (I can't have the program open all the time, so
>that's not a viable solution)?

Well, there is another solution, with an AppleScript.  Try something like this:

  on GetURL (myURL) -- or whatever you need for the handler
    tell app "MacPerl" to Do Script [myScript, myURL]
  end GetURL

Play around and see what happens.  :)

-- 
Chris Nandor       |     pudge@pobox.com      |     http://pudge.net/
Andover.Net        | chris.nandor@andover.net | http://slashcode.com/

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