Count of minor children: 0 REPEAT Child Info IF AGE( ChildBirthDate-d ) < 18 RESULT + 1 END IF END REPEAT Filter for Minors ("FilterMinors-c"): AGE( ChildBirthDate-d ) < 18 List of Chilren: (requires the filter above) "" REPEAT Child Info FILTER FilterMinors-c FORMAT "A, B and C" RESULT + ChildName-t END REPEAT List of Chilren (columnar): (requires the filter above) "" REPEAT Child Info FILTER FilterMinors-c RESULT + ChildName-t + "\r" END REPEAT
The proper way to filter for minors is to check their age with AGE( date ) < 18 (returns TRUE or FALSE), where "date" is a date variable that indicates the child's birthdate (ChildBirthDate-d above).
The first computation counts the number of minor children and returns that number. It accomplishes this by adding 1 to RESULT only if the child is less than 18.
The second computation is a filter to be used in repeated dialogs. It returns TRUE if the child is a minor, otherwise FALSE. This filter is used in the next two computations (as FilterMinors-c).
The next computation creates a list of minor children in the format "Jimmy Johnson, Sally Johnson and Aaron Johnson." The FILTER line calls our minor children filter and causes the REPEAT to skip any answers that fail to meet the filter's criteria (less than 18 years old). The FORMAT line indicates how we want the list formatted. And the RESULT line adds the next answer to the list. This list is returned by the computation.
The last computation is identical to the previous except that the list will be formatted:
Jimmy Johnson
Sally Johnson
Aaron Johnson
The carriage return is placed with "\r." For other ways to insert a carriage return, see Computation #0012: Returns in Text Strings.
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.