53. Smart Salutation -- Married Couples
Description
Generates a multi-party salutation that will selectively format for either married couples (Dear Mr. and Mrs. Jones) or for non-married parties (Dear Mr. Jones and Ms. Johnson).
Code
Addressing correspondence to multiple parties can get tricky. Sometimes the parties are completely unrelated and need to be addressed as "Mrs. Adams, Mr.Bell and Dr. Call." Other times they are a married couple that should be addressed as "Mr. and Mrs. Duke." And other times still they are married but have different surnames: "Mr. Evans and Mrs. Frame."
Code
IF AreMarried-b AND COUNT( PartiesDialog ) = 2 AND LastName-t[1] = LastName-t[2]
"Dear «Title-t[1]» and «Title-t[2]» «LastName-t[1]»:"
ELSE
"Dear "
REPEAT PartiesDialog
FORMAT "a, b, and c"
RESULT + "«Title-t» «LastName-t»"
END REPEAT
END IF
Explanation
First, you would want to ask up front whether the two parties are married, since the simple fact that they have the same last name is not conclusive. This is held in the true/false variable AreMarried-b. Also, you have to worry about married couples that do NOT have the same last name. Finally, you must check to make sure that there are only two parties [as opposed to less or more than two].
The computation checks to see if 1) the parties are married to each other, 2) there are exactly two parties, and 3) they have the same last name. If all of these are TRUE, the computation will create a salutation in the form "Dear Mr. and Mrs. Jones" or "Dear Dr. and Mrs. Jones", etc. If any of the aforesaid are not true, the salutation will simply be a listing of all party names entered. For example, "Dear Mr. Jones and Ms. Johnson", or "Dear Mrs. Frame", or "Dear Mrs. Hardy, Mr. Ott, and Ms. Snow".
The text variable Title-t could just as easily be a multiple choice variable that contains the title for the person: Mr. Mrs. Ms. Miss. Dr. Col. Pres. etc.