More on Mac::AppleEvents, Mac::OSA

pudge on 2002-12-10T20:13:18

I was having problems with AEDescs because I was putting data into Handle using strlen() to get the size. strlen() just figures out the length of a C string, up to the first null. I wanted to use the length from AEGetDescDataSize() or GetPtrSize(). But I didn't.

Mac::OSA::Simple works pretty well, though I need to release a new version to support Mac OS X. I can do stuff like:

use Mac::OSA::Simple; my $play = compile_applescript('tell app "iTunes" to play'); my $pause = compile_applescript('tell app "iTunes" to pause');

sub play { $play->execute } sub pause { $pause->execute }


Calling play() and pause() are much much faster than calling DoAppleScript($script) over and over again, because the compilation phase of the AppleScript is time-consuming. This kind of thing should work fine now, but return values are broken (the way AEPrint() returns data has changed, and I was using that instead of $desc->get), as is saving a script to disk (e.g., $pause->save($filename); my $script = load_osa_script($filename, 1);; this is related to the problem of my current FSSpec routines requiring files to exist, which needs to be fixed).

So I won't be releasing the new Mac::OSA::Simple too soon; I want to first see about addressing my issues with the FSSpec routines, and I need to revamp how I release modules (bug reporting, CVS, releases on CPAN and SourceForge.net, etc.).