Mac::Stuff

pudge on 2003-06-04T17:18:36

I've had several requests before to make OSA scripts accept arguments. For example, in Mac::OSA::Simple, you can do, for a saved script:

tell application "iTunes" play end tell

This:

my $play = load_osa_script('itunes_play'); $play->execute;

But what if you want to play a specific track? You don't want to recompile your script, because that is inefficient (it can take awhile to compile an AppleScript, plus you don't want little AppleScripts all over the place).

So I mostly have it worked out that you will be able to pass arguments to your compiled AppleScript. What the code will look like, with the AppleScript:

on «event abcd1234» (trackname) tell application "iTunes" play (first track of library playlist 1 whose name is trackname) end tell end «event abcd1234»

and the Perl code:

my $play = load_osa_script('itunes_play'); $play->call('abcd', '1234', 'Pearls Before Swine');

And on the command line or whatever, you could have simply:

% iplay "Pearls Before Swine"

That's the plan, anyway. I have it working (the low-level stuff). I found a bug in Mac::OSA::OSADoEvent where the reply event was not getting filled out, so it was failing, so it will require a newer Mac::Carbon. I'll do it sometime this summer.

And yes, I know, Mac::Carbon is still slow when loading the extensions, in some cases. I'll work on that this summer, too. :-)

Now Playing: Most Likely You Go Your Way And I'll Go Mine - Bob Dylan (Biograph)


test

pudge on 2003-06-05T12:11:47

foo! ま