Using Variables
Using Variables
Variables can be used in many parts of the system, mainly in the following two scenarios:
- Rich Text Box: The rich text box is the input box in the questionnaire editor whose border turns purple when it gains focus. Variables can be inserted into it. If the border of an input box turns blue when it gains focus, it is a regular input box and variables cannot be inserted into it.
- Carry Forward: Select variables from the variable panel that pops up during option reference.
Inserted variables will be displayed as tags in different colors to distinguish them from regular input content.
Variable Selector
To use variables, you need the variable selector. Input the "@" symbol in a rich text box,

or click the Carry Forward button, both actions will bring up the variable selector. Enter keywords in the filter input box at the top to filter variables.

The variable selector lists all variables available at the current location. The variable selector displays in the following order:
- System Variable Group: Contains all system variables.
- Explicit Variable Group: Classifies variables by type and divides the explicit variables of the questionnaire into multiple explicit variable groups, with each group containing variables of the corresponding type added in the variable panel.
- Implicit Variable Group for All Nodes: Each node in the node name list can output a set of variables, known as implicit variables.
Before the variable names in the list, small dots of different colors are used to distinguish different variable types. Hovering the mouse over a project group will list the variable subsets under that group.
Using Variables in Rich Text Boxes
Input the "@" symbol in a rich text box to bring up the variable selector panel. Click on the desired variable, and it will be inserted into the current rich text box. Inserting variables in rich text input boxes such as question text and option text will result in the variables being resolved to their actual values during the answering process.
For example:
- Inserting the System Variable/Basic/Questionnaire ID in question text will show the variable being resolved to the current questionnaire's ID.
- Inserting the variable All Options/Number of Options extracted from a previous multiple-choice question will show the variable's value being resolved to the number of selected options in subsequent questions when certain options are selected for this question.
Apart from being inserted into question content, numerous properties used to control question characteristics also allow for variable insertion, such as the maximum and minimum number of options for multiple-choice questions, and the maximum number of input characters as control conditions. When variables are used in these properties, the control conditions are first resolved into specific values, which are then validated.
Numeric Spinner Control
The numeric spinner control is a special numeric setting control in the system. Under certain conditions, it switches to a rich text box form to accept variables. A small button is located on the right side of the numeric spinner control. Clicking this button toggles the input mode between the following:
- N: Numeric input mode, allowing direct numeric input.
- V: Variable input mode, where the numeric input box transforms into a rich text box, enabling variable insertion in the same way as in rich text boxes.
For example, when enabling multiple-choice options for a question, you will see that the input boxes for setting the maximum and minimum number of options are numeric spinner controls.
On the right side of the control input box, there are two buttons with up and down arrows. Clicking these buttons or pressing the up and down arrow keys on the keyboard increments or decrements the value in the input box. Holding down the Shift or Alt key simultaneously changes the increment/decrement step.
Using in Carry Forward
Click the Carry Forward button, select the desired variable from the pop-up variable selector, and then generate the option reference setting for creating corresponding referenced options.
Additional Variable Settings
For variable tags and option reference configurations inserted in rich text boxes, clicking on a variable will bring up a variable filter. This allows filtering and selecting the desired variables based on logical conditions.
Variable Restriction Rules
During variable setting, the system filters out usable variables based on the attributes of the location where the variable is inserted. If a variable exists but cannot be found in the variable selector, check the following rules to determine if the reference restriction rules are met:
- In a question node, only implicit variables from questions before the current question node can be referenced, and those after the current question are not displayed.
- If an implicit variable of a question node is referenced in an explicit variable, then no questions before this question can reference this explicit variable.
- Media variables can only be referenced in places that support media display.
- HTML variables can only be referenced in places that support HTML rendering.
- If a variable contains an error, it cannot be referenced.
Resolving Null Values
If a variable is referenced but its value cannot be resolved during runtime, a default null value ' ' will be resolved.