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

RE: [MacPerl] MacPerl, AppleEvents and Timeouts



Excellent. This looks like it's hugely useful, just the sort of thing I'm
looking for, and a lot simpler than the way I've been trying to do it, all
of which are good things. (I've learned a boatload about AppleEvents,
though, which was one reason for rolling my own. Come to think of it, I
learned Perl in much the same way.) Thank you very kindly.

And in answer to a couple of the questions you ask, in no particular order:

- No, I haven't tried Mac::Glue. I picked it up when I first started working
on this stuff, but I don't remember why I haven't looked further into it.

- I don't know what card/clos is either. It's something CaptureAE reported
that Frontier was sending. There were also a bunch of events being reported
as being sent by "Application Switcher," but leaving all that out doesn't
seem to have affected the script. Since I'm quitting Frontier immediately
after I run the script, card/clos may not be that important.

- I looked at your tutorial about two weeks ago. I'd love to look at it
again when pudge.net comes back. :D

Thanks again,

-- Creede

-----Original Message-----
From: Chris Nandor [mailto:pudge@pobox.com]
Sent: Thursday, July 22, 1999 11:44 AM
To: Creede Lambard (Volt Computer)
Cc: 'macperl@macperl.org'
Subject: Re: [MacPerl] MacPerl, AppleEvents and Timeouts


A couple of notes.

* Have you tried Mac::Glue?  It makes a lot of this easier.
* If you don't want to use Mac::Glue, there is also
Mac::AppleEvents::Simple.

Both of these allow you to set a timeout parameter.  In Mac::Glue, you can
do:

  $frontier = new Mac::Glue 'Frontier';
  $frontier->do_script($script, TIMEOUT => 9999);

In Mac::AppleEvents::Simple:

  $event = build_event(qw[misc dosc LAND], "'----':TEXT(\@)", $script);
  $event->send_event(kAEWaitReply, kAENormalPriority, 9999);

However, both Mac::Glue and Mac::AppleEvents::Simple (Mac::Glue uses
Mac::AppleEvents::Simple) default to no timeout, so specifying the timeout
is not even necessary.

Of course, you can roll your own as you are doing (nothing wrong with that)
and set the timeout by hand in AESend.

   AESend($event, kAEWaitReply, kAENormalPriority, kAEDefaultTimeout);

kAEDefaultTimeout and kAENormalPriority are the defaults.
kAEDeafultTimeout can be changed to kNoTimeout, and it will never timeout.
Or, you can change it to a number of ticks (some really big number like
9999*3600).


* In case you haven't seen it, there is a tutorial (that needs to be
updated) about Apple Events under the MacPerl Help.  I have a somewhat
updated version of of it on my site (which is down for a few days, could be
up at any time).  But it needs to be revamped.

* There is also a Mac::OSA::Simple module (and a Mac::OSA module), which
includes frontier() function.  Were I going to do this, I would probably
try:

  #!perl -w
  use strict;
  use Mac::Apps::Launch;
  use Mac::Files;
  use Mac::OSA::Simple;

  my $path = FindFolder(kOnSystemDisk, kDesktopFolderType) .
      ":Frontier";  # get the correct version of Frontier to launch
  LaunchSpecs($path, 1) or die $^E;  # launch with path and bring to front

  # execute frontier script
  frontier('local.verbs.myscript("parameters")');

  # i don't know what card/clos is ... ?

  # quit Frontier
  QuitApps('LAND');

I dunno if that would timeout or not on the frontier() call, but it sure
makes things easier when calling Frontier.  Hope that all helps, though.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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