Computation Editor

You use the Computation Editor in Component Studio to create and edit scripts in computations to accomplish tasks such as defining a custom interview, or calculating values that you can place into assembled documents.

To access the Computation Editor, you can:

In this topic Hide

  1. Common Tasks
  2. Component Toolbar
  3. Component Identity Properties
  4. Script Tab
  5. Behavior Tab
  6. Notes Tab
  7. Tools Pane

Common Tasks

Component Toolbar

Basic component actions appear in the component toolbar, above the component properties.

Button What it Does
Test Displays the selected component in the HotDocs Test Browser.
Rename Displays the Rename Component dialog that enables you to rename your component.
Duplicate Displays the Duplicate Components dialog that enables you to create a copy of this component in the component file.
Tools Shows or hides the Tools pane on the right.
Delete Displays the Delete Component dialog that enables you to delete the component. You can also view a list of templates or components that currently reference the selected component and you may have to fix after deletion.

Component Identity Properties

At the top of the editor you can see the name that HotDocs uses to identify this computation, the expected result type, and any parameters.

Property Name What it Does
Name Enables you to view and edit the name of your component. This field is editable for a component that is not referenced by a template or other component; otherwise, it is a non-editable box containing the name of the component. If non-editable, use Rename in the component tool bar.
Result type Enables you to select an output type for your computation from:
  • Text
  • Number
  • Date
  • True/False
  • None

If you set the result type of the computation you create to anything other than None, and the computation doesn't return a value of the Result Type you select, HotDocs shows an error and underlines the location in your script in red.

Parameters Enables you to create new parameters by clicking the create button (image) or view a list of existing parameters which you can drag and drop into a script.

You can right-click on an existing parameter to rearrange the parameters list (Move Left or Move Right) or delete (Remove)the selected parameter but this will affect any templates or other components which reference this computation.

Script Tab

You can use the script tab to create a HotDocs script.

In addition to the interface elements below, if you start typing in the Script tab, HotDocs uses an auto-complete feature to help you write correct syntax.

Element What it does
Find (CTRL+F) Opens the Find dialog so you can search for specific text within your script. Check boxes enable you to search based on the case of the text you type, as well as searching for entire words.

Alternatively, search your script by pressing Ctrl+I, and then type the text you want to find. If the search finds the text, pressing Ctrl+I again searches for another instance of the text lower in your document, while pressing Ctrl+Shift+I highlights the previous instance.

Find Next (F3) Enables you to search your script for another instance of the text you already searched for using the Find dialog. Check boxes enable you to search based on the case of the text you type, as well as searching for entire words.
Find and Replace (CTRL+H) Opens the Find and Replace dialog, so you can search for and replace text within your script.
Line numbering Adds (or removes) line numbers to the script editor.
Go To Enables you instruct HotDocs to place the cursor at the line number or character position you provide.
Auto format Indents matching pairs of instructions based on the level of their insertion.
Indent block Indents the selected block of text.
Unindent block Unindents the selected block of text.
Comment block Tells HotDocs to ignore the selected block of script.
Uncomment block Tells HotDocs to remove the comment tag on the selected block of script.
Export computation Places the computation on your clipboard so you can paste it into a different script editor or use it externally (e.g. in an email or text file).
Locals (Local Variables) Enables you to create new local variables when you click the create button or view a list of existing local variable which you can drag and drop into a script.

You can right-click on an existing local variable to delete it.

Behavior Tab

The Behavior tab provides you with properties that enable you to change how a component behaves during assembly:

Property Name What it does
Default format

Enables you to set the format for every placeholder field that references the computation throughout the template. The format you select formats the computation's resulting value when the resulting value replaces the computation's placeholder field during assembly; for example, you could use the 'nine' number format to spell out a numeral you compute using the SUM function.

Setting a default format does not override any formats you have already (or will) set for an individual placeholder field using the HotDocs Field Editor.

Default unanswered text

Enables you to specify what text you want HotDocs to merge into the final document when a user leaves the variable unanswered. This text overrides the Unanswered variable placeholder users can select in the Template Properties window.

Pad answer to fixed number of characters Enables you to change how answers are displayed in the assembled document by altering the padding of the answer according to the characteristics you specify using the following properties:
  • Padded width – enables you to specify, by selecting a fixed number of characters, the width of the area in the assembled document that contains an answer
  • Answer alignment – enables you to specify the alignment of the answer in the area of the assembled document that contains an answer:
    • Left the answer appears first, followed by the appropriate amount of pad characters
    • Right the appropriate amount of pad characters appear first, followed by the answer
  • Pad character – Enables you to specify which character HotDocs uses to pad any spaces left over if the answer doesn't use all the width you specify in the Padded width property. If the answer is shorter than the padded width, HotDocs inserts the necessary number of pad characters.

The default fill character is a space.

Notes Tab

To provide you a quick way to know if this tab contains any content, you can see a + symbol on the tab if there is a note.

As you create components, you may want to include notes to remind yourself of decisions you made when creating the component. For example, maybe you need to remember information about restrictions you applied to a Number variable, or remind yourself of the purpose of the component in the template.

The notes tab enables you to type any notes you want about the component and its role in the template.

This information is not visible in the interview; it is for the author’s reference only.

Tools Pane

On the right side of the component editor you can view a tools pane containing various (Components, Models, Used in, or Field Editor) tabs for this component.

You can use the Tools button on the Component toolbar to show or hide the tools pane.

Components Tab

Displays a filterable list of components contained in the component file.

Right-click on a component in this list to view a quick actions menu that enables you to: Edit, Rename, Cut, Copy, Paste, or Delete a component.

Element What it Does
Search box Enables you to quickly locate components within the component file that you can add to the current component. As you type, search results display immediately. You can clear the search box by clicking X.
Filter (All Components) You can filter your search results by the following parameters you select the various options::

All Components – displays all components all variables in your component file

  • All variables – displays all variables in your component file
    • Variables in Dialog (this filter only available in a Dialog component's Script tab) displays only the variables that have been added to the current dialog   
    • Text Variables displays only the Text variables in your component file
    • Number Variables displays only the Number variables in your component file
    • Date Variables displays only the Date variables in your component file
    • True/False Variables displays only the True/False variables in your component file
    • Multiple Choice Variables displays only the Multiple Choice variables in your component file
  • Dialogs displays only the dialogs in your component file
  • Computations displays only the computations in your component file
  • Dialog Elements displays only the dialog elements in your component file
Sort (drop-down arrow) Enables you to sort the component file's components. You can choose between the following sort options:
  • by Name—sorts components by their names from A to Z
  • by Type—places Dialogs  first, then Dialog Elements, then computations, then variables (starting with Multiple Choice); items of each type are sorted within their type depending on settings Natural and Reverse
  • Natural—sorts components from A to Z
  • Reverse—sorts components from Z to A

Select Multiple

To select all of the components in the component list pane, press Ctrl + a on your keyboard.

The right-hand pane presents a shortened list of options in multiple-select mode.

Create Enables you to create a component depending on the type you select in the drop-down list.

If you set the Filter (All Components) on the left to a given type, the create button displays and creates this type when you click the create button.

Component list pane Displays the contents of the component file according to search parameters, sorting, and any filters or multiple selection you apply. Select a component from the list to view it in the right pane, or double-click a component to pin it open for editing.

Models Tab

Displays the list of instruction and expression models that are available for you to use in this script. To add one or more models to the script, drag and drop them into the script editor. Then you can drag items from the Components tab or Locals tab and drop them on the model placeholders to complete the line of script.

You can see different models in the expanded lists depending on whether you are creating a computation or a dialog script. Two expanders, Dialog Instructions and Dialog Validation Functions, are only available in when you are creating a dialog script.

Locals Tab

The Locals tab appears in the Tools pane after you create at least one local variable or parameter for your script. This tab contains the local variables and parameters that are available for you to use in the current script. You can add a local variable or parameter to your script by dragging and dropping it from the right pane into the script editor.

To reorder parameters, right-click in the parameters section of the locals tab and click Move Up or Move Down. Because a computation containing parameters may be used in multiple locations, be careful when rearranging the parameters. The computation may depend on the parameters being answered in a certain order to make a script work, so changing the order may cause the computation to malfunction elsewhere.

You can only insert a parameter when working with a computation script. Parameters are not available for dialog scripts.

Used In Tab

When you select a component in the Components column of Component Studio, you can look in the Used In tab to see the list of other components or templates (if there are any) that use the component you select. Double-clicking an item in the Used In tab opens that item for editing and places focus on the first reference to the component you selected.