i was quite impressed when i read Chris annoucement of the release of the OSA::Simple module a few weeks ago and today i found the time to try it. Basically this is a two part question, first i wondering why things are not working the way i thought and then i want to improve what i thought. Here is what i'm talking about :-)
I have a bundle of MacPerl scripts using MacPerl::DoAppleScript to include Applescript for launching other apps, etc. I know that this is slow but i never was able to use AppleEvents directly so i'm fine with it.
Now i thought maybe a compilation via compile_applescript would lead to some decrease of processing time. So i tried a simple thing like:
use Mac::OSA::simple;
my $mp = compile_applescript(<<'EOMP') or die $!; with timeout of 300 seconds tell application "OS9:Applications (Mac OS 9):CMacTeX 4.2:binaries:mpost" activate quit end tell end timeout EOMP
$mp->execute;
and it works fine, i.e. it starts the Metapost application from Tom Kiffe's CMacTeX and quits it immediately. If i try to use a command line like
exec "mpost test.mp" in the folder alias "OS9:Desktop Folder:"
between 'activate' and 'quit' it works fine too, i.e. Metapost processes the file and i get the resulting eps-file.
But if i try to put two variables instead of the explicit file and path it is not working. Of course the two variables are defined before.
The following script:
#!perl
use warnings; use strict;
use Mac::OSA::Simple;
my $mpcommand = "mpost text.mp"; my $path = "OS9:Desktop Folder";
my $mp = compile_applescript(<<'EOMP') or die $!; with timeout of 300 seconds tell application "OS9:Applications (Mac OS 9):CMacTeX 4.2:binaries:mpost" activate exec $mpcommand in the folder alias $path quit end tell end timeout EOMP
$mp->execute;
leads to:
# OS9:Desktop Folder:simpletest.pl syntax OK # Operation not permitted. File 'OS9:Desktop Folder:simpletest.pl'; Line 11
Line 11 is the compile_applescript statement.
Of course all this does not lead to a big decrease in processing time. So the final goal would be to compile a script which reads two arguments when it is executed, in this case the filename and the path. And then execute it several times at runtime with different files. Is this possible?
Best regards, Martin
-- (1) Never draw what you can copy. (2) Never copy what you can trace. (3) Never trace what you can cut out and paste down.