In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Ken Williams) wrote:

> Chris, would it be fun/possible to convert all that applescript to perl?

Yep.  Note that currently you cannot "tell" an object in Mac::Glue, but no 
big deal; that is just syntactic sugar.  You'll see that apart from that, it 
is basically a line-by-line translation of syntax, using the same words but 
in Perl.

   use Mac::Glue ':all';

   my $mail = new Mac::Glue 'Mail';

   my $msg = $mail->make( new => 'outgoing message' );
   $mail->set( $mail->prop( visible => $msg ), to => gTrue() );

   my $last_char = $mail->obj( character => gLast(), of => content => $msg );
   $mail->make(
       new => 'attachment',
       at  => location( after => $last_char ),
       with_properties => {
           file_name => "/etc/motd"
       }
   );

   $mail->activate;

The most difficult thing is to know what it means, for example, to tell 
newMessage to set visible to true.  In this case, it means the same as set 
visible of newMessage to true, where visible is a property, so we 
prop(visible => $msg), to => gTrue().  Yay fun.

See similar fun with the location insertion record for "after last character 
of content of message" (the extra "of" in the perl is because content is a 
property and not an object ... at some point I want to get rid of that extra 
verbiage, which should be possible).

See the Mac::Glue POD for more details.

Of course, this currently works only in MacPerl (but the script above does, 
in fact, work from MacPerl in Classic to control Mail.app).  But as noted 
before, I am working to finish porting it all to work under Mac OS X, and 
most of the pieces are in place, I just need to find the time to finish it 
all up.  Before summer.  :)

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to