Re: Mac::Glue and Address Book
On Jul 4, 2004, at 1:23 PM, Chris Nandor wrote: In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ken Williams) wrote: When I get a record from the Address Book like so: use Mac::Glue ':all'; my $ab = Mac::Glue->new('Address Book'); my $person = $ab->obj( people => whose(AND => [[ first_name => begins_with => 'Smorgasbord' ], [ last_name => equals => 'Milhouse']] ); I can't seem to tell the difference between someone who doesn't exist in the Address Book, and someone who exists but has no phone number (or address, or whatever). Any tips on how to do this? I am not sure what you're asking. Are you saying someone who exists but doesn't have any contact info -- just a name -- won't be returned by this? I works for me (modifying your parens/brackets slightly): print my $person = $ab->obj( people => whose(AND => [ first_name => begins_with => 'S' ], [ last_name => equals => 'Wonder'] ))->get; That returns for a card for the name Stevie Wonder, with no other info. If I change it to "Sn" "Wonder", I get an uninitialized value warning in the print. Ah, I see - I was trying to tell the difference between a "hit" and a "miss", i.e. a search that found someone and a search that didn't. Looks like I can use defined($person->get) for it, thanks. -Ken
Re: Mac::Glue and Address Book
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ken Williams) wrote: > When I get a record from the Address Book like so: > >use Mac::Glue ':all'; >my $ab = Mac::Glue->new('Address Book'); >my $person = $ab->obj( people => whose(AND => > [[ first_name => begins_with => 'Smorgasbord' ], > [ last_name => equals => 'Milhouse']] ); > > I can't seem to tell the difference between someone who doesn't exist > in the Address Book, and someone who exists but has no phone number (or > address, or whatever). Any tips on how to do this? I am not sure what you're asking. Are you saying someone who exists but doesn't have any contact info -- just a name -- won't be returned by this? I works for me (modifying your parens/brackets slightly): print my $person = $ab->obj( people => whose(AND => [ first_name => begins_with => 'S' ], [ last_name => equals => 'Wonder'] ))->get; That returns for a card for the name Stevie Wonder, with no other info. If I change it to "Sn" "Wonder", I get an uninitialized value warning in the print. -- Chris Nandor [EMAIL PROTECTED]http://pudge.net/ Open Source Development Network[EMAIL PROTECTED] http://osdn.com/
Re: Krazy Mac::Glue entities
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ken Williams) wrote: >use Mac::Glue ':all'; >my $ab = Mac::Glue->new('Address Book'); >my $person = $ab->obj( people => whose(AND => > [[ first_name => begins_with => 'Smorgasbord' ], > [ last_name => equals => 'Milhouse']] ); > > the $person object is absolutely nuts. It's got about a million > key-value pairs that look like this: > > bless( { >'GLUE' => bless( { > 'IDS' => { > 'mbox' => { >'name' => > 'mailbox_url' >}, > 'JPEG' => { >'name' => > 'jpeg_picture' First, note that GLUE is just a reference to the $ab object. It's not specific to $person. So how this works is that all Apple event dictionaries inherit from the installed "dialect" (and can also include other dictionaries, via OSAX). So in Script Editor, you can do: tell application "Finder" get (count of items) as square kilometers end tell There's really no way to know which enumerations, classes, etc. that a given dictionary might use, so we suck them all in. Yes, this can cause some problems with bloat, which is why many longtime AppleScript developers will caution you about not installing OSAX you don't need or aren't using. See _merge_classes and _merge_enums in Mac::Glue if you're curious on the details. I tried various methods of optimizing it, but nothing seemed to help, that I tried, without adding more complexity for no significant gain. See gluedoc -d AppleScript and gluedoc -a StandardAdditions for the most common stuff that's slurped into each glue. > Is this, like, every four-letter Apple ID that has ever lived? Or can > I really find out how many degrees Kelvin my friends are? tell application "Address Book" get (count of people) as degrees Kelvin end tell ==> degrees Kelvin 614.0 :) -- Chris Nandor [EMAIL PROTECTED]http://pudge.net/ Open Source Development Network[EMAIL PROTECTED] http://osdn.com/
Krazy Mac::Glue entities
Um, When I do the following: use Mac::Glue ':all'; my $ab = Mac::Glue->new('Address Book'); my $person = $ab->obj( people => whose(AND => [[ first_name => begins_with => 'Smorgasbord' ], [ last_name => equals => 'Milhouse']] ); the $person object is absolutely nuts. It's got about a million key-value pairs that look like this: bless( { 'GLUE' => bless( { 'IDS' => { 'mbox' => { 'name' => 'mailbox_url' }, 'JPEG' => { 'name' => 'jpeg_picture' }, 'left' => { 'name' => 'left' }, ... 'sqkm' => { 'name' => 'square_kilometers' }, ... 'ednb' => { 'name' => 'nubus_card' }, ... 'ksb^@' => { 'name' => 'f7_key' }, ... and so on and so forth. Among other highlights: 'kilometers', 'ovals', 'arrow_at_both_ends', 'degrees_kelvin', and 'as_taught_in_school'. Is this, like, every four-letter Apple ID that has ever lived? Or can I really find out how many degrees Kelvin my friends are? -Ken