In this article
The Syntax Highlighter functionality means that while scripting you no longer need to remember the functions, or look up which properties belong to which classes and which parameters the various methods accept. Instead, all these are available at the touch of a button. The highlighter automatically color-codes key words, and provides lists of selectable options under specific conditions while scripting.
The Syntax Highlighter functionality is on by default for a survey, but you can switch it off in the User Settings (go to User Account Settings for more information).
The following script editing areas support the highlighter capabilities:
- Script nodes in authoring
- Validation and masking of questions
- Reportal scripting
- Data Processing scripting
- JavaScript editors
To use the highlighter, start typing into the scripting area the function you wish to use, then press the Ctrl+Space keys on your keyboard. A drop-down list of all the functions corresponding to the text string you have typed, opens. To open a complete list of all the available functions, press Ctrl+Space without first typing anything into the scripting area.
The figure below shows the Syntax Highlighter in action:
Figure 1 - Example of the Syntax Highlighter in action
Using the System Highlighter
When writing code, you can automatically get a list displayed with classes, functions, methods or properties relevant to the context you are in, covering both Authoring specific and general JScript.NET constructions. To display the list:
- Press CTRL+space to display the list.
- Type more characters to reduce the number of items in the list and jump directly to a member in the list. Use the arrow buttons to move up and down in the list.
- Press Enter to select an item.
- After the name of a function or method, type an open parenthesis (as you normally would) to open the Parameters list.
- Press ESC at any time to close the list.
If you have already started typing, the list will be filtered according to the typed string. After the name of a class or variable, the list will appear automatically when you type period (.).
On functions and methods, a parameters list will automatically pop up to give you information about the number, names and types of parameters required by a function, template, or attribute - . The parameter in bold indicates the next parameter that is required as you type the function. Where there are different versions of the function with different parameter lists, you can select which parameter list you wish to view.
Figure 2 - Example of the Syntax Highlighter functionality in use
To view parameter information:
The declaration for the function will pop up under the insertion point. The first parameter in the list appears in bold. To switch among functions, use the UP or DOWN arrow keys. As you type the function parameters, the bold changes to reflect the next parameter that you need to enter.
Use Tab to indent lines of code. Lines of code within curly brackets, { and }, will automatically be indented. To indent several lines of code in one operation, mark all the code you want to indent and press Tab. To un-indent, press Shift+Tab.
Syntax Highlighter Limitations
The Syntax Highlighter has some limitations. No autocompletions are available for implicitly typed objects (objects returned by functions etc.) so
Typing:
f()will not result in an autocomplete suggestion.
Typing:
var d = new Date();
d.
will not result in an autocomplete suggestion.
Typing:
var myDate: Date;
myDate.
will result in an autocomplete suggestion.