I have found there are things I can do in Applescript that I can't do in
MacPerl and more so the opposite way around.  What is nice is that using
AppleScript from MacPerl is mostly a pretty good solution when you need to
do Applescrit things.  One way to glue them together is to use the Script
editor to record the actions you wish to base some operation on and then use
that as a here document in MacPerl, sending the here document to AppleScript
via

&MacPerl'DoAppleScript("${script}");

Note that the return value of the script is the return value of the
applescript call, so you can use this in constructing further calls.

I have found that calling Applescript from MacPerl often leads to the
application not being found.  In Applescript this only occurs the first time
a script is run (as I recall) but it always occurs when calling from
MacPerl.  The work around for this that I have used is the following.

$script = "tell application \"Finder\" \n";
$script .= "  open application file id \"SIT!\"\n";
$script .= "  set appName to name of result\n";
$script .= "end tell\n";
my($tval) = &MacPerl'DoAppleScript($script);

You need to know the 4 letter code for your application for this.


-John




        ----------
        From:   Crook, Richard  W
        Sent:   Monday, March 11, 2002 3:15 PM
        To:     [EMAIL PROTECTED]
        Subject:        [MacPerl] AppleScript vs MacPerl

        Hi everyone,

        Just a quick question/survey. I'm taking over an system written
mostly in
        AppleScript and some MacPerl. Is it worth sticking with the
AppleScript or
        should I port it over to MacPerl. I suppose the answer will be
obvious
        considering the list I'm spamming but I thought it might be
interesting to
        hear some opions about the topic.

        Thanks!

        Rich Crook


Reply via email to