Slow down, I’m not asking the script to do anything illogical and perverse.
My scenario is this: when I fire up the script, the search string defaults to the last contact I searched for, and it automatically includes her entire title and name. I have not gone out of my way to include the title—the script does this by automatically. But that’s fine--so far, so good. However, if I press <return> at this point, the script can’t open that contact until I delete the title or retype her name without the title. Logically, from the user’s point of view, if I go with the default, I should get that contact opened. Instead I get an error.
That’s what didn’t make sense.
Now, if it is impractical to implement, I can understand that. But your solutions below are downright confusing.
--
Mervyn
on 19/12/2000 11:28 AM, Paul Berkowitz at [EMAIL PROTECTED] wrote:
On 12/17/00 5:56 PM, "Mervyn Sinaga" <[EMAIL PROTECTED]> wrote:
> Paul,
> This is going to be very useful to me. Thanks.
>
> I've been running it this morning and there's one annoyance--the script
> returns a "I can't find that contact..." message when I have the title in
> the search string. I like the seeing the title for some bizarre reason, so I
> like the script it the way it is--except that the script fails to find that
> contact unless I remove the title from the search string.
>
> Can fix?
I'd hardly call something so "bizarre" as requiring a "fix", more a "weird custom adjustment"> I presume you're talking about "Open Contact Name" which can find a contact about 3 different ways. Probably you're selecting the name in text somewhere? Try this:
In the TryDisplayName(theSelection) right at the bottom of the script, you'll find a line:
set theNames to (name of every contact whose name contains theSelection)
Change it to:
set theNames to ((name of every contact whose name contains theSelection) as list) & ((name of every contact whose name is in theSelection) as list)
Then make sure you select the ENTIRE NAME along with the title, or it won’t work.
The suggestion I give above only works if the name part of the selection contains the entire name entered in the Address Book. That’s the only way to do it. You’d better not include any middle initials anywhere.
But here’s a more reliable way to make sure it opens: DON’T include the title when you select (duh).
I mean, what am I suppose to say if the next person writes saying “I like to select three lines plus add a musical example.” Either you want the contact to open, or you don’t. I’ve already provided several different ways to get it open. There’s no way of telling the script “Check every part of the selection against every combination of title plus name plus maybe some other nonsense.” What would happen then is that it will suggest almost every single contact in the Address Book since almost every contact (well, at least half of them) will include at least one character (letter) that you have selected. So it can’t be scripted to be that free. You also can’t say
set theNames to (name of every contact whose (name & " " & title) contains theSelection)
if you were hoping for something of that sort. That doesn’t work. You’d have to do that by repeat loop which would take forever. You’d still be waiting 30-60 seconds later if you have a large address book. This is how to do what you really want:
set allContacts to (every contact)
set theNames to {}
repeat with theContact in allContacts
set contactName to name of theContact
if contactName contains theSelection then set end of theNames to contactName
if ((title of theContact) & " " &contactName) contains theSelection then set end of theNames to contactName
end repeat
That would be the reliable way to pick up your selected title + name, when it wouldn’t matter if you missed a letter or two. In the time it takes for that to work, you could have gone to the Address Book, typed in the name, opened the Contact, done this with 7 other contacts and had a cup of coffee.
I’m sorry, but scripting isn’t actually magic, you know, even if it seems that way. It’s logical. If you’re going to be illogical and perverse, you’re bound to be disappointed in it.
--
Paul Berkowitz
