Determine When to Use A or An

From HotDocs Wiki

Jump to: navigation, search
NOTE:

HotDocs 2006 (and later) users: You may use the «.an» dot code to merge the correct article. See the HotDocs Help for a description.

When automating templates, you may want to use a variable in a sentence, preceded by the article a or an based on how the user answers the variable. If the range of answers a user may enter is limited and known during template development, you can ensure that the correct article will always be used. For example, if the user will always enter one of the 50 United States, you can create a computation that will insert the correct article for any state.

In the case of a limited number of possible answers, using a Multiple Choice variable is one way to guarantee the user will choose only a valid answer. Then, you can include the correct article for each option in the merge text for that variable. For example, if the user must select an occupation from a list, the Multiple Choice variable options may be Attorney, Doctor, Secretary, Teacher, and Editor. The corresponding merge text would be an attorney, a doctor, a secretary, a teacher, and an editor.

Another option is to write a computation to determine which article to use, which you place in front of the variable in your template. Then, when the document is assembled, HotDocs examines the answer entered for the variable and, following the logic of the computation, determines whether to insert a or an.

The following computation shows how to determine the article based on the assumption that words beginning with a vowel are preceded by an, and all other words are preceded by a. Caution: This computation will not produce perfect results in all cases. For example, if the user's answer begins with the word union, the computation will return an even though the correct article is a. Although you can alter the computation to consider certain words a user is likely to use that do not follow the general rule, carefully proofreading the assembled document is always recommended.

Example

"" 
IF "aeiou" CONTAINS FIRST( Text Var, 1 ) 
  "an" 
ELSE  
  "a" 
END IF

Text Var Any Text variable.