To simplify script implementation, the script editor provides an array of useful features. The following section describes how the editor:
Checks and highlights the syntax.
Allows you to search and replace.
Provides code suggestions.
Shows the data model's structure.
When you write your code in the script editor, it displays in different colors based on the category of terms. This feature improves readability and allows you to distinguish between different contexts.
If your code is syntactically incorrect, the script editor automatically raises alerts. In line three of the example below a red 'X' indicates a problem. By hovering over the icon, a message alerts you to the missing element. The yellow caution icon indicates a warning that might not break your code, but really is not a best practice either.
This basic - yet important function - can greatly assist you in keeping long and complicated code under control. The script editor supports both finding and replacing code.
You can use the 'Search' function by pressing the 'Ctrl + F' key combination. The search box contains the following features:
The up/down arrows highlight the next, or previous occurrence of the search term found.
The 'All' option closes the search box and highlights every occurrence found with a flashing cursor.
The three icons in the lower right of the search box allow you to toggle between using: regular expression search, case sensitive search and whole word search.
Use the key combination of 'Ctrl+H', to display the 'Replace' feature. Enter your replacement text in the box and click 'Replace' to update individual occurrences, or click 'All' to update all found occurrences.
The script editor's auto-suggestion feature helps speed up the process of coding by reducing typos and other common mistakes. A main function of this feature is that it provides suggestions about methods associated to predefined objects.
When using a script implementation, most tasks require you to frequently enter node paths. Correctly remembering each path in the data model can be very difficult. And, if you type paths incorrectly, the script will not work. To alleviate this burden, the script editor can display your data structure, allow you to select a node, and insert its path.
To use the 'Data structure' panel:
While working in the 'Script' tab, click 'Data structure' to open the panel and display a structural view of your current data model.
To add a node's path to the script, hover your mouse over the node you want to add and click insert. As shown in the following image, the path inserts at your cursor's current position.
Note that the 'Data structure' panel only displays the model of the data set on which the rule executes.