In this article
Most Surveys contain some script code. Scripts are used:
- In conditions for controlling the flow through the Survey (skipping logic).
- In column masks (3D grids) and question masks to control whether or not a question should be displayed.
- To filter the lists displayed in questions and the iterations in loops based on previous answers (code masks/scale masks).
- In form elements for text substitution (response piping).
- For custom validation of user input.
- In general-purpose code contained in script nodes.
Authoring uses the Microsoft JScript .NET scripting language. The runtime environment of the interview engine (or simply the runtime) supplies a number of functions and objects that provide references to survey variables and allow you to manipulate them.
Authoring uses the Syntax Highlighter functionality (go to Syntax Highlighter for more information).
A syntax highlighter is enabled by default in all areas where scripts can be written. This includes Authoring script nodes, masking and validation scripting, as well as scripting in Reportal. When the syntax highlighter is in use, each time the Tab key is pressed, the line of script is indented one step. Each press of the Shift-Tab keys removes one indent from the line. Note that the Tab key does not insert a tab in the text.
To disable the syntax highlighting functionality, check “Disable script highlighting” in the User Settings overlay (go to User Account Settings for more information).
Note: The functions mentioned herein are described in the context in which they are most commonly used, and are not described in great detail. These functions are not restricted to being used in only this context.
Script Nodes
Script nodes typically contain code for the following purposes.
- Internal programming purposes
- Defining functions used in code masks, conditions, other script nodes or validation code
- Setting the values to hidden variables
This requires more intimate knowledge of Jscript.NET than can be presented in this document.