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

Re: [MacPerl] Passing values between AppleScript and MacPerl



At 4:33 PM +0200 2/18/99, Sean Carte wrote:
>I'm still relying extensively on AppleScript to do certain things. I know
>that there are ways of doing them in MacPerl, and I'll get around to
>learning them in time; for now, however, I find MacPerl::DoAppleScript()
>very useful.
>
>One thing I'm battling with, though, is passing values between MacPerl
>and AppleScripts embedded in the same script.

Chris's comments about using Reply inside a Do Script inside a
DoAppleScript aside, in general you pass values TO AppleScript by taking
advantage of the quotish nature of here documents, and you pass values FROM
AppleScript by capturing the return value of DoAppleScript

For instance, if I do this:
$aNumber = MacPerl::DoAppleScript("get 1");

$aNumber will hold 1 (well, it might hold "1").

and if I do
$x=5;
$y=6;
$aNumber = MacPerl::DoAppleScript(<<EOS);
display dialog "Enter $x + $y" default answer ""
get text returned of result as number
EOS

It will ask me to enter 5+6, and set aNumber to whatever I type in (if it
can be coerced to a number).

-Jeff Lowrey




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch