At 13:04 +0100 2002.03.12, Bart Lateur wrote:
>It depends on what you want to do. AppleScript is extremely slow as a
>generic programming language, but OTOH, in order to control external
>apps, calling an Applescript embedded in a Perl script takes a very long
>time to compile -- which will have to happen every single time. The
>alternative is raw AppleEvents, but it's very hard to write stuff in,
>compared to plain AppleScript. Check out the modules Mac::AppleEvents,
>Mac::AppleEvents::Simple, Mac::Glue. (They appear to come with the new
>MacPerl 5.6.)
Yes, they do.
>OK, silly question from me... has anybody written a tool, or a part of a
>tool to convert Applescript source code into code directly usable by one
>of these modules? Something along the lines of the B::Deparse, but for
>Applescript... I guess not...
No, although, you can take AppleScript and compile it with Mac::OSA::Simple
(or Mac::OSA, of course). You can compile it to memory or to disk, and
then execute it later. It can be far more efficient than DoAppleScript,
obviously.
use Mac::OSA::Simple;
my $script = load_osa_script($path, 1); # boolean for loading from file
$script->execute;
One thing that would be nice would be to make execute() accept parameters
somehow, so that you may pass in variables to a script. Mac::OSA and
::Simple are not used much, so not much work is done on them, but if
someone wants these things, they can help me work on that.
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Development Network [EMAIL PROTECTED] http://osdn.com/