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

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