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

Re: [MacPerl] MacPerl->Applescript->MacPerl



>I have searched Sandra Silcott's MacPerl archive but couldn't find what I
>wanted.
>
>I want to write a cgi that calls an Applescript Applet, which after doing
>it's nasty little thing will return data to the CGI for spittage out to the
>Browser.
>
>
>#!perl
>
>
>$times = 4;
>
>MacPerl::DoAppleScript(<<END_SCRIPT);
>tell application "Yet Another Test"
>        set $x to doMe($times)
>end tell
>END_SCRIPT
>
>print $x;
>
>
>the Applescript just returns "You've been done $times times". But of course
>i don't get nuttin'

Your script should get $times into the AppleScript code (perl just
interpolates the string). But you don't get anything back from AppleScript
unless you write something like:

#!perl
$times = 4;

$x = MacPerl::DoAppleScript(<<END_SCRIPT);
tell application "Yet Another Test"
        doMe($times)
end tell
END_SCRIPT

print $x;

whatever your AppleScript returns as result in the Script Editor ends up in $x;

Here a snippet I use myself:

$path = MacPerl::DoAppleScript(<<ENDIT);
tell application "Finder"
        (path to extensions folder) as text
end tell
ENDIT

print "$path\n";


hope that helps,

hansmartin



--
/ Hans Martin Lehmann          []  Wiesendangerstr.4          \
| E-Mail: hmlehman@es.unizh.ch []  CH-8003 Zurich/Switzerland |
| Phone: (41 1) 462 18 51      []  Kleegaertenstr. 57         |
\        (41 28) 46 29 75      []  3930 Visp                  /