Re: AB: Finding a contact from the phone number??
Re: AB: Finding a contact from the phone number??
- Subject: Re: AB: Finding a contact from the phone number??
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 06 May 2003 06:42:46 -0700
As Michelle pointed out already, 'some phone' means 'random phone' - it
could be any phone number at all from the list of phone numbers for each
person. I'm not even sure that a 'whose' clause is meant to work with 'some'
anything, since 'some' is not an application property but an AppleScript
term. If it _did_ work, you should expect to get a different result every
time since it means 'random'. But I wouldn't expect it to work, just like I
wouldn't expect
get value of phone of people whose {value of every home phone} contains
{searchNumber}
to work because the {} interferes with the whose clause, whereas I _would_
expect this to work:
get value of phone of people whose value of every home phone contains
{searchNumber}
(Note that the resulting list of (every home phone) is a list and requires
{} braces around the contains operand, although string list terms will be
coerced OK to single-item lists so even this will probably work:
get value of phone of people whose value of every home phone contains
searchNumber
You can't just use your own notion of what 'some phone' means to you in
English and expect it to work in AppleScript. Its meaning is defined in the
ASLG and it corresponds to just one specific meaning of 'some' in English,
namely 'a random item from the list of every items'.
This time, there's nothing wrong with Address Book, but with your code. To
get what you're looking for, you need the repeat loop in the second example.
--
Paul Berkowitz
>
From: Jakob Peterhdnsel <email@hidden>
>
Date: Tue, 6 May 2003 10:27:36 +0200
>
To: Applescript List <email@hidden>
>
Subject: Re: AB: Finding a contact from the phone number??
>
>
Hi All.
>
>
Ok, I might have a error-prone Address Book DB, since this code returns
>
different results:
>
>
my findContactFromPhone("163806")
>
--> {}
>
my find_contact("163806")
>
--> {record with my card, containing the correct phone.}
>
>
on findContactFromPhone(searchNumber)
>
tell application "Address Book"
>
ignoring white space
>
get value of phone of people whose (value of some phone contains
>
searchNumber)
>
end ignoring
>
end tell
>
end findContactFromPhone
>
>
>
on find_contact(search_number)
>
tell application "Address Book"
>
repeat with myperson in people
>
repeat with myphone in phones of myperson
>
set phone_number to value of myphone as string
>
--set phone_number to (characters 2 thru (length of phone_number)
>
of phone_number) as string
>
ignoring white space
>
if phone_number contains search_number then
>
return {contact_info:myphone, person_info:myperson}
>
end if
>
end ignoring
>
end repeat
>
end repeat
>
end tell
>
end find_contact
>
>
>
So, now I'm puzzled! Is my AB database corrupt, or...
_______________________________________________
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.