Punctuate a Sentence-Style List of True/False Variables

From HotDocs Wiki

Jump to: navigation, search
NOTE:

HotDocs 2006 (and later) users: You may use the list punctuation dot code to correctly punctuate a list of nonrepeated answers. See the HotDocs Help for a description.

You can let users select one or more answers from a list of possible options in a dialog by using a Multiple Choice variable or a group of True/False variables. If you use a Multiple Choice variable, merging the list of selected options as a punctuated list is relatively easy. You can insert a variable field in your template and assign the Multiple Choice variable to it with a list format such as a, b, and c:

 The house was «MChoice Var:a, b, and c».

However, if you use a group of True/False variables to determine which words to include in the document, you cannot use a list format. Instead, you would typically have to include a series of IF instructions, as follows:

 The house was «IF Red»red«END IF»«IF Red AND Blue» and «END IF»«IF Blue»blue«END IF».

As you can see, the number of IF instructions can quickly add up, especially if you want to ensure correct punctuation between options. Fortunately, there are alternatives you can use in your templates. The following example shows how to use a computation to place the selected True/False answers in a Multiple Choice variable and then use that Multiple Choice variable in the document.

CAUTION: This computation sets a Multiple Choice variable to multiple values, which works only in HotDocs 6.1 SP1 and higher.

The following computation consists of a series of IF instructions to create a string of text for each true answer, separated by pipe ( | ) symbols. At the end of the computation, this text string is used to set the answer for a Multiple Choice variable. To use this computation in a template, place the Computation variable (Comp Var) before the Multiple Choice variable (MChoice Var) in the template. Then use a list format like any other Multiple Choice variable, such as a, b, and c:

 The house was «Comp Var»«MChoice Var:a, b, and c».

Example

"" 
IF TrueFalse Var 1 
  RESULT + "red|" 
END IF
IF TrueFalse Var 2 
  RESULT + "blue|" 
END IF
IF TrueFalse Var 3 
  RESULT + "white|" 
END IF 
IF TrueFalse Var 4 
  RESULT + "green|" 
END IF
SET MChoice Var TO RESULT
"" //This clears the result of the computation.

TrueFalse Var 1 Any True/False variable.
TrueFalse Var 2 Any True/False variable.
TrueFalse Var 3 Any True/False variable.
TrueFalse Var 4 Any True/False variable.
MChoice Var This is a temporary Multiple Choice variable with the Select option set to All That Apply. (See Create a Temporary Variable.) It must also have at least one option, which is simply a placeholder.
Comp Var A Computation variable (see script above).