Re: birth date from Address Book
Re: birth date from Address Book
- Subject: Re: birth date from Address Book
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 13 Mar 2003 07:37:43 -0800
On 3/13/03 6:47 AM, "Darwin Zins" <email@hidden> wrote:
>
I apologize for being slow here. I see in the dictionary where it says:
>
Class application: Users address book database
>
Elements:
>
group by name, by numeric index, before/after another element, as a
>
range of elements, satisfying a test, by ID
>
person by name, by numeric index, before/after another element, as a
>
range of elements, satisfying a test, by ID
>
document by name, by numeric index, before/after another element, as a
>
range of elements, satisfying a test
>
window by name, by numeric index, before/after another element, as a
>
range of elements, satisfying a test, by ID
>
>
The by name part I suppose is what tells me that I can tell person
>
"Darwin Zins".
Yes.
>
It never even occured to me to do it that way because
>
you can have multiple people with the same first and last name. I just
>
tested that and tell person name always returns the first person it
>
finds with that name.
This is quite normal, in other apps too. The "first person it finds with
that name", if there is more than one, is generally the first one to have
been created. That should been "lower ID number" but I don't know how those
complex ID numbers work.
>
I am now doing it this way:
>
tell application "Address Book"
>
set found_in_a to true
>
set thePerson to z_first_name & " " & z_last_name
That won't work when the person has only a first name OR last name, but not
both. Then you shouldn't have a space, which would be a trailing or leading
space. (Address Book actually removes trailing and leading spaces in all
field entries so it could never end up in the name anyway.) If there's no
first OR last name, the 'name' property still applies using the company. If
there's no company either, 'name' uses the first email address. i think it
gives up after that point and just leaves the name blank - it shows up as
<No Name> in the Name list. You can confirm all of this by just looking at
the nam list for contacts with missing name fields.
What this means, if you're importing from another app like your Zaurus, is
that you need a more complex routine to get at what Address Book considers
the name. At the very least (and you can do this outside the Address Book
tell block before you begin it), something like:
if z_first_name /= "" and z_last_name /= "" then
set theName to z_first_name & " " & z_last_name
else
-- will cover all other possivilities
set theName to z_first_name & z_last_name
end if
if theName = ''"
if z_company /= "" then
set theName to z_company
else if z_email1 / = "" then
set theName to z_email1
else
exit repeat
end if
end if
------------------------
If a contact doesn't have first name, last name, company or email address,
its name will be blank. You do NOT want to be calling 'person ""', so you
should skip this one and move on. One way of doing that is by including
immediately witin you mail epeat loop and second repeat loop that just
'repeat 1 times':
repeat with i from 1 to (count theContacts)
set theContact to item i of theContacts
repeat 1 times
-- stuff here
if somethingOrOtherDoesn'tFit then
exit repeat -- skips just this item
end if
--more stuff
end repeat
end repeat
>
set aCard to person thePerson
>
try
>
last name of aCard
>
on error
>
set found_in_a to false
>
end try
>
if found_in_a is true then
>
>
I suppose what I really need to do is create an external mapping file
>
that maps the Apple AB ID to the Zaurus AB ID. I just wanted to get it
>
to actually sync by First Name and Last Name and then add that later,
>
but now the Script Editor keeps telling me that I have no more room to
>
add any characters. Is the only option at this point to buy the Script
>
Debugger from LNS (other than making the code smaller :)
No (although I use SD myself). You can also get Smile script editor, which
is free and has no text limits and lots more which make it much better than
the SE toy. There are links to Smile, and SD, from Apple's AppleScript web
page.
>
>
Darwin
>
>
On Wednesday, March 12, 2003, at 05:51 PM, Darwin Zins wrote:
>
>
>> And here it is. It seems very long-winded to get properties like
>
>> that. If Address book sucks, as it does, then the last thing that's
>
>> needed is to make a meal of its shortcomings. The thing can be done
>
>> quite simply like this
>
>>
>
>> tell app "Address Book"
>
>> set birthday to person "John Delacour"'s birth date
>
>
>
> Is this for real? Can you do something like:
>
> set thePerson to "John Delacour"
>
> set aCard to person thePerson
>
>
>
> What happens if thePerson doesn't exist in the Address Book? Is it
>
> fast to look up that person? I currently have:
>
> repeat with aCard in (every person where last name is z_last_name and
>
> first name is z_first_name)
>
>
>
> Thanks,
>
>
>
> Darwin
>
> _______________________________________________
>
> applescript-users mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/applescript-users
>
> Do not post admin requests to the list. They will be ignored.
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
>
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.