[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Interfacing to AppleEvents



At 20.14 97/6/14, Tom Pollard wrote:
>Until it's easier to generate AppleEvents, I'd say it's inaccurate to call
>MacPerl a "scripting language" at all.  Perl (and MacPerl) is a
>full-fledged programming language, certainly.  To my way of thinking it
>qualifies as a scripting language for Unix because it makes it easy to
>link together other Unix programs together with the 'system' call and the
>backtick notation, but on the Mac it's really only useful as a
>self-contained programming language. It doesn't really work too well yet
>as a way to glue other Mac applications together, and this is the essence
>of what "scripting" is.

Disagreed.  It depends on what your tasks are.  If you don't need to glue
apps together, and you simply need to do text processing and basic system
interaction, then why would Perl not suit your scripting needs?


>For MacPerl to become a useful scripting language for the Mac, I think
>it's basically going to have to become an AppleScript interpreter in
>addition to what it is now.  AppleScript is the closest thing on the Mac
>to a command line interface and it's the common language which all Mac
>applications speak.  If you accept that, then it would make sense for the
>'system' command and the backtick notation to interpret their arguments as
>AppleScript in MacPerl.

Please, no.
1.)  A fundamental problem with AppleScript is its syntax.  Why continue to
use it?
2.)  AppleScript is NOT the closest thing to a command line interpreter on
a Mac.  That would be MPW.
3.)  AppleScript is NOT a common language all Macs speak.  Apple Events
are.  AppleScript puts a user language (one I don't particularly like) on
top of the Events.
4.)  AppleScript from MacPerl will alwyas be slower than AEs straight from
MacPerl, because AppleScript has to be compiled first.  It takes an extra
step.
5.)  If you want to use AppleScript from MacPerl now, you can do it
similarly to how you asked to do it.  Except instead of backticks you use
the MacPerl::DoAppleScript command.
6.)  It would be much nicer for Perl programmers, and probably the Mac
scripter at large, if AppleEvents would be used from standard Perl
object-oriented syntax.  There are ways to do that now with AEStreams.  But
that, as I said, is prohibitively difficult for most programmers.

Right now, to disconnect from OT/PPP requires this:

#!perl
use Mac::AppleEvents;
$evt = AEBuildAppleEvent('netw','RAdc',typeApplSignature,'MACS',0,0,'')||die $!;
AESend($evt, kAEWaitReply) || die $!;

Maybe something like this would be better:

#!perl
use Mac::AppleEvents;
AEBuildSend('netw','RAdc','MACS');

The other stuff stays the same for most all AE calls.  So maybe just a
simplified syntax would be a start.  And I don't know the guts of how
AppleScript gets its "words", but maybe MacPerl could grab the same English
words used by AS:

DoAE('','PPP disconnect') || die $!;
#first variable is blank since command is sent to Finder

And for connect:
DoAE('','PPP connect',{address=>'555-1212',
                       'user name'=>'chrisn',
                       password=>'pass'}) || die $!;

Obviously, a lot of AEs get more complicated than that, too.  But it's just
an idea of how they might look.  I know that it looks beautiful to me.

--
Chris Nandor                 pudge@pobox.com                 http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6'])



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch