Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Wednesday June 04, 2003
12:18 PM


[ #12618 ]

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"
end tell


my $play = load_osa_script('itunes_play');

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)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.