I have this script
tell application "Address Book"
set myPerson to person 4
set {workMail, homeMail} to {"", ""}
tell myPerson
set workMail to value of first email whose label = "Work"
set homeMail to value of first email whose label = "Home"
end tell
return {workMail, homeMail}
end tell
which works fine if myPerson has both a home and a work e-mail entry.
If that person doesn’t have a work e-mail, an error occures.
If I put the set statements inside a single try block, and the person has no work e-mail, the error sends exicution to the end of the try block and misses the home e-mail
So, I have multiple try blocks.
tell application "Address Book"
set myPerson to person 4
set {workMail, homeMail} to {"", ""}
tell myPerson
try
set workMail to value of first email whose label = "Work"
end try
try
set homeMail to value of first email whose label = "Home"
end try
end tell
return {workMail, homeMail}
end tell
Is there a way to put the set statements inside a single try block?