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

Re: [MacPerl] Passing values between AppleScript and MacPerl



At 09.33 -0500 1999.02.18, Sean Carte wrote:
>One thing I'm battling with, though, is passing values between MacPerl
>and AppleScripts embedded in the same script. Would I be correct in
>stating that the way to do this is by following the examples on
>pp.249-250 of MPPE, like this:

No, you saw nothing like this in MPPE!

>-----------
>#!perl -w
>use strict;
>my($result, $script);
>$result = "";
>$script = <<EOS;
>tell application "MacPerl"
>  return Do Script "MacPerl::Reply(join ('|', ('a'..'g')))"
>end tell
>EOS
>$result = MacPerl::DoAppleScript($script) or die("Could not run script:
>$!\n");
>print("$result\n");
>-----------
>This dies with the error: "No such file or directory".

MacPerl can only run one script at a time.  You are asking MacPerl to tell
AppleScript to ask MacPerl to do something, and asking MacPerl to wait for
an answer.  But AppleScript needs the first script to finish before it can
ask MacPerl to do anything.

You don't really ever need to do anything like that.  Rather than asking
AppleScript to ask MacPerl to return something, just do it in MacPerl in
the first place.  This accomplishes the same thing:

  #!perl -w
  use strict;
  print join ('|', ('a'..'g'));

I know you probably know that and were just trying out an example.  But
since there is no reason that I can think of to ever need to do such a
thing ... :)

--
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 mac-perl-request@iis.ee.ethz.ch