In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> I just found out about this list

Oops, I thought you knew about it.  :)

> maybe someone here will have the glue
> wisdom needed to answer the question I just posted in my journal...
> 
> Why does this work:
> 
>    tell application "iCal"
>      tell last calendar
>        make new event at end with properties {summary:"foo"}
>      end tell
>    end tell 
> 
> But not this:
> 
>  use Mac::Glue qw(:glue);
>  
>  my $ical = new Mac::Glue "iCal";
>  
>  my $calendar = $ical->obj(calendar => gLast);
>  print $calendar->prop("title")->get, "\n\n";
>  
>  $calendar->make(
>    new => 'event',
>    at  => location('end'),
>    with properties => { summary => "foo" }
>  );

$calendar->event is not directly analagous to tell $calendar to event.  What 
$calendar->event does is make $calendar the direct object of event.  To 
spell it out, the perl translates back to:

   tell app "iCal"
      make last calendar new event ...

Whereas the AppleScript itself can be translated to AppleScript as:

   tell app "iCal"
      make new event at (end of last calendar)

So the proper syntax is:

  $ical->make(
     new => 'event',
     at  => location(end => $calendar),
     with properties => { summary => "foo" }
   );

In theory, we could make $calendar->make work, but I am not sure of the best 
way to figure out the proper location() object and add $calendar to it.  It 
would be a bit complicated.

It's one more reason to be hateful of AppleScript: it's so hard to know 
exactly what belongs to which part of speech, and tell blocks are one of the 
prime examples.  Why isn't "last calendar" the direct object of make, but 
instead, of end?  Computer languages aren't supposed to make you guess this 
much.  :)

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

Reply via email to