The HotDocs Computation Archive
Get Extra Help

0112 - Record & Paste Data

Description:

Allows you to selectively record and paste repeated dialog data.


• Code •

(Dialog Script)

SET Index-n TO COUNTER
 
 
(RecordData-c Computation)

ADD "«Index-n:09» - «FullName-t»" TO PasteFrom-m
 
 
(PasteData-c Computation)

SET Temp-n TO INTEGER( PasteFrom-m )
IF Temp-n > 0
   SET Street-t TO Street-t[ Temp-n ]
   SET CityStateZip-t TO CityStateZip-t[ Temp-n ]
   SET Phone-t TO Phone-t[ Temp-n ]
END IF
 
 
(ClearList-c Computation)

""
CLEAR PasteFrom-m
ADD "<Select an item to paste>" TO PasteFrom-m

• Explanation •

(Note: To create this system, you must have HotDocs Pro).

This set of computations allows the user to "record" any number of repeated dialog screens and then selectively "paste" that data on future screens.

The repeated dialog has a button called Record this Data. When the user clicks this button, the information on the current screen is recorded.

The dialog also has a simple drop-down list. All recorded entries appear on this list. The user can select a record from this list and then click a Paste button. This will cause the data from the selected record to be pasted into the fields of the current screen.

This is similar to Computation #0076: "Same as Above", only it has the advantage of allowing you to bring any previous answer forward. It is ideal for name-gathering dialogs, especially "master name table" dialogs (see, Computation #0105: Internal Database Tables).

Required Elements:

After creating your dialog and the computation variables, add the dialog script above to the dialog. Then add buttons for the two computations RecordData-c and PasteData-c. To create the first button, type the following in the "Additional Text" window of the dialog, then drag it into place on the list of variables:

@COMPUTE:RecordData-c:Record This Data

Repeat this process for the next button, using this value: @COMPUTE:PasteData-c:Paste.

The Nitty-Gritty. The key to this working is the Index-n number variable. Notice that all the dialog script does is SET Index-n TO the current COUNTER value. We must do this in the dialog script because COUNTER is not available outside of that script. With each cycle of the repeated dialog window, the COUNTER level gets dumped into Index.

If the user chooses to "record" a dialog screen, the RecordData-c computation is invoked. All that this computation does is create an entry in the PasteFrom-m list for the current dialog window. The entry is simply the current Index-n value followed by the FullName-t of the individual. The FullName-t is provided as an easy point of reference for the user; but all that the computations really care about is the Index-n value.

If the user chooses to "paste" into a dialog screen, they simply need to select an item from the PasteFrom-m menu and click on the PasteData-c computation's button, thus invoking the computation. This computation tries to extract the index value from the front of the selected PasteFrom-m value using the INTEGER model, SETting it into the temporary number variable Temp-n. If an index value is successfully extracted, the computation then SETs each variable on the dialog to Variable[ Temp-n ].

You may decide what values are or are not pasted. This is determined exclusively by the PasteData-c computation. Note that the computation will overwrite any existing values in the current dialog window. To prevent this, simply check for an existing value before each SET statement:

IF ANSWERED( Variable ) = FALSE
   SET Variable TO Variable[ Temp-n ]
END IF

Clearing the List. All entries added to the list are saved to the component file as options for PasteFrom-m. But when you start a new assembly, you obviously don't want the left-over items from the last assembly. To make sure that your list gets a fresh start with every assembly, create the ClearList-c computation above, then make sure that it is placed at the very top of your template so that it is run at the beginning of assembly.

The one drawback to the ClearList-c computation is that it will not remember your list between assemblies if you re-use the same answer file. To store the state of PasteFrom-m in an answer file, add a true/false variable called AddToList-b to your RepeatedDialog. You may want to HIDE this variable in the dialog script. In the RecordData-c computation, add this line:

SET AddToList-b TO TRUE

Finally, modify the ClearList-c computation as follows:

""
CLEAR PasteFrom-m
ADD "<Select an item to paste>" TO PasteFrom-m
ASK NONE
REPEAT RepeatedDialog
   IF AddToList-b = TRUE
      ADD "«COUNTER:09» - «FullName-t»" TO PasteFrom-m
   END IF
END REPEAT
ASK DEFAULT

The modified ClearList-c computation clears the list, then iterates through RepeatedDialog for records that were marked for adding. Each time it finds such a record it adds it back to the list.

 

• 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)

 
 

• Contributors •

LegalCS