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

Re: [MacPerl] Calling Perl script from AppleScript/"run script" osax



>Well, I admit it, I've been asking this before, but I didn't get a solution.
>

[stuff about Applescript deleted]

Hi Michael,

When I started programming in perl I met the same problem, more or less. I
wanted address a scriptable Mac program via applescript, but within two
days I didn't figure out how applescript works, while perl was just very
easy. So I managed to write only the essential Applescript task, without
looping and data-manipulation, and called it from my perl script. I used
the MacPerl documentation (version 5.06 at that time) with the following
example, and it worked for me (adaption with "variable" for test purposes
by me).

By the way, I use the Appliction MacPerl, but it worked also from a Runtime
script. Only make sure Applesscript is installed on the destination
computer!

Each variable which has to be changed is created in perl, and inserted in
the applescript just like with the "print here-document" syntax.

Be sure to quote all variables in the applescript, note the $txt variable below:

-----

#!/usr/local/bin/perl


$txt = "Inserting text the hard way.";


&MacPerl::DoAppleScript(<<"END_SCRIPT");
tell application "MacPerl"
        make new Window
        copy "$txt" to character 1 of front Window
end tell
END_SCRIPT

-----

Hope this helps you,

Regards, Joe

-------------------------------------------
finger for PGP <jlpoutre@pop4.inter.nl.net>