The HotDocs Computation Archive
Get Extra Help

0127 - Combine Multiple Repeat Dialogs into One

Description:

How to combine a series of lists gathered from variables on multiple repeated dialogs into a single list consisting of one variable on one repeated dialog. Effectively combines many lists into just one.


• Code •

SET Counter-n TO 0

ASK NONE
REPEAT Dialog 1
        SET Counter-n TO Counter-n + 1
        SET CombinedVar[Counter-n] TO Dialog1Var
END REPEAT

REPEAT Dialog 2
        SET Counter-n TO Counter-n + 1
        SET CombinedVar[Counter-n] TO Dialog2Var
END REPEAT

REPEAT Dialog 3
        SET Counter-n TO Counter-n + 1
        SET CombinedVar[Counter-n] TO Dialog3Var
END REPEAT
ASK DEFAULT

• Explanation •

The purpose of this computation is to combine multiple lists into one. For example, suppose that you have three different repeated dialogs, each containing a specific type of asset. Dialog 1 contains Cash Accounts, Dialog 2 contains Retirement Accounts, and Dialog 3, Life Insurance Policies. You would now like to combine the user's input for each of those dialogs into one list, called, simply, Assets (Dialog 4) so that you can produce a list of all assets. This computation shows how to do that.

The computation requires one temporary number variable called Counter-n. Select all of its "Advanced" options. The computation also assumes three repeated dialogs (Dialogs 1 - 3) which would correspond to the individual asset dialogs. Each dialog contains one variable (Dialog1Var - Dialog3Var), which would be the variables to hold the names of the assets. The values from these variables will be combined into a single variable called CombinedVar which is placed on the Assets repeated dialog.

The computation uses Counter-n as an independent counter that passes through each of the repeated Dialogs 1 - 3 and constructs Dialog 4 on the fly, always adding the next value as a new repeat iteration on Dialog 4 with SET CombinedVar[Counter-n] TO ...

It is recommended that you clear Dialog 4 prior to running this computation. This is described in Computation #0071: Clear a Repeated Dialog.

This technique is based on Computation #0004: Copy a Repeated Variable and forms the basis for Computation #0105: Internal Database Tables.

 

• Contributors •

Lee Knight
Consultant
(619) 255-4986
(Home Page)