The HotDocs Computation Archive
Get Extra Help

0002 - Count how often a Multiple Choice answer was selected

Description:

Counts how many times each option of a MC variable was selected in a REPEAT.


• Code •

""
SET Option1-n TO 0
SET Option2-n TO 0
SET Option3-n TO 0

REPEAT RepeatedDialog
   IF MultipleChoice-m = "Option 1"
      SET Option1-n TO Option1-n + 1
   ELSE IF MultipleChoice-m = "Option 2"
      SET Option2-n TO Option2-n + 1
   ELSE IF MultipleChoice-m = "Option 3"
      SET Option3-n TO Option3-n + 1
   END IF
END REPEAT

• Explanation •

The computation requires one Number variable for each option of the Multiple Choice variable (Option1-n, Option2-n, etc.).

The computation variable walks through the REPEAT, incrementing each of the number variables as their option is chosen. Then finding out how many times a given option was selected is as simple as looking at the value for the corresponding number variable.

 

• Model Template •

This template has everything you need set up and configured for you. It will work as-is, or can be adapted to your variable and dialog names. It contains: 1) sample Word and WordPerfect templates (or an Automator form) to demonstrate an implementation of the computation, 2) a component file containing the computation and all supporting dialogs and variables, and 3) instructions for adapting the computation for your use.

(Go to the download page)