Script Editor

Script Editor

Script editor

The figure below shows the ESL script editor window. Each script is opened in its own tab.


1

Toolbar.

2

The breakpoint is set when debugging a script 

.

3

The source text of the script - individual actions that form the script.

4

The part of the script editor that contains the following displaying:

  • Compile - errors that occurred during the compilation (syntactic, semantic check),

  • Debug - debugging logs,

  • Notations - comments existing in the script,

  • Watch - values of local variables

  • Evaluate - expression evaluation

To resize this part and the area for editing the script text point the mouse cursor to the margin between the parts and when the mouse cursor changes its shape to

, then press the left mouse button and drag the border (left mouse button has to be still pressed) to the desired position.

5

Status bar

6

Minimap for fast navigation in code


Notes:

When the script editor is closed all the tabs will be closed and the window will hide.

The rules of the tab closing:

  • script of the active picture (opened in D2000 GrEditor) does not display the question of whether to save the script providing that there were made some changes (the script is occupied by the edited picture),

  • script of the event (opened in D2000 CNF or D2000 GrEditor) displays the question of whether to save the script providing that there were made some changes

ESL editor features:


  • Automatic color differentiation of keywords:

    .

  • Automatic color differentiation of texts: correctly written:

    , incorrectly written:
    .

  • Semantic coloring - different colors for local, global, predefined and scheme variables, different colors for objects, procedure names etc...

  • Static code analysis

  • After a successful Syntax check:

    • Typing the symbol '^' after the name of an object of Structured variable type or after the name of a local variable of RECORD type shows the list of all structure columns with the column number and description. The columns are listed in alphabetical order.

    • Pointing the mouse cursor to a local variable, or a structured variable item displays information about its type and the place where it is declared (in the debugging mode, the value of the variable is shown).

  • After an unsuccessful Syntax check or Compilation, double-clicking an error from the lists of errors (5) moves the mouse cursor to where the error occurred. Another possibility for navigation between errors or warnings is by clicking on an icon in the upper right corner of the editor, which is shown when there are some errors or warnings. After clicking on this icon, a line with an error is shown with an error description. Every other click on the icon shows the next error/warning.

  • Pressing F1 (help) when the cursor is pointed to the name of a function/action opens the help document for the given function/action/picture event.

  • Quick navigation in a script using a minimap (code outline). To move quickly in the script, you can click and drag the gray part in the minimap to move the currently displayed part of the script in the editor. The minimap contains highlighted pieces of code, such as the line with the cursor position. In the case of a failed syntax check or compilation, error lines are highlighted here in red, or warning lines are highlighted in orange. After placing the cursor in the editor on a local variable or procedure, all occurrences of the given variable/procedure within the script are displayed in gray behind the slider.

  • Automatic suggestions occur under the following conditions:

    • After entering the "\" character after the object or variable, when a list of object attributes is displayed

    • After entering the character "^" if this character is located after an object of type structured variable or after a local variable of RECORD type 

  • Autocompletion and suggestions in the editor after pressing the CTRL + SPACE keyboard shortcut. After pressing CTRL + SPACE again, it is possible to display a more detailed description (function - description of function, action - syntax for action, variables - description of variable, constants - description of constant). It is possible to navigate in the list of suggestions using the arrows, after pressing ENTER the given action, variable, function, constant, or attribute will be added. Based on the conditions described below, it contains a list of proposals:

    • If there is a space in front of the cursor in the editor, actions, variables, functions, and constants are suggested

    • If the cursor is preceded by a text beginning with "%", the functions are suggested, and the list of suggestions is filtered based on the text after "%"

    • If the cursor is preceded by a text beginning with "_", the proposed variables (local, global, and schema variables in the case of a schema script) are filtered, and the list of suggestions is filtered based on the text before the cursor.

    • If the cursor is preceded by a text beginning with "@", constants are suggested, and the list of suggestions is filtered based on the text after "@"

    • If the cursor is preceded by a text beginning with a-zA-Z, action keywords are suggested

    • If the line starts with the keyword of the action, the current options will be displayed first in the list, followed by all the options for completion provided by the editor (variables, functions, constants).

    • If an object identifier (schema object or system event server identifier) ​​is specified for the CALL action, RPC procedures and interfaces that are defined for the object are proposed.

  • Automatic display of function parameters after entering the function name and the first parenthesis. The currently typed parameter is underlined and highlighted. The popup with the description of the function parameters can be displayed even after placing the cursor in the editor between the function parameters and pressing the keyboard shortcut CTRL + SHIFT + SPACE

  • After typing the "^" character after the interface name, a list of procedures that are defined for that interface is displayed. After selecting an item from the list, the procedure definition is added to the ESL Editor.

  • Preview the definition or references of a local variable and procedure, without the need to change the position in the script. By activating, the nested editor is displayed in the desired position with the possibility of editing, while previewing references, it is possible to gradually switch between individual occurrences in the right part. This functionality is invoked via the popup menu Peek → Peek Definition (ALT + F12) or Peek → Peek References.

  • Folding / unfolding parts of the script such as: procedure body, BEGIN-END, IF-ELSE, IF-ELSIF, IF-ENDIF, FOR-END_LOOP ... The icons for folding/unfolding are located to the right of the line number, while the icons for folding are shown only if we move the cursor over this part of the editor.

  • Automatic indentation
    When writing the ESL script and moving to the new line, the ESL editor automatically indents the current line (according to the first non-zero line) and moves the cursor on the given position. The indent size is automatically detected from the current script, but can also be adjusted in the status bar (Figure area 6).

    Features of automatic indentation:

    1. When moving to a new line after selected actions (eg RPC, PROCEDURE, PUBLIC, FOR, DO_LOOP, IF ...) in the ESL editor, the text is automatically indented by the defined size.

    2. When moving to a new line after selected actions (eg END_LOOP, ENDIF ...) in the ESL editor, the text is automatically indented by a defined size to the left of the previous line.

    3. When you press CTRL + K and then CTRL + F, the highlighted text is formatted according to the previous properties. The indent of the first line in the marked set of lines is decisive for this action.

    4. Pressing SHIFT + ALT + F will format the entire text

  • Column text selection is possible by pressing SHIFT+ALT and then by dragging the mouse

  • Basic keyboard shortcuts:

    Shortcut

    Action

    Shortcut

    Action

    CTRL+F1

    Display the complete list of actions together with keyboard shortcuts

    F1

    Display editor help, if the cursor is over the function name, help for the function is displayed





    CTRL+SPACE

    Show suggestions

    CTRL+SHIFT+SPACE

    Show quick info for procedure and function parameters





    CTRL+K CTRL+C

    Comment current line or comment selected block of text

    CTRL+K CTRL+U

    Uncomment the current line or uncomment a selected block of text

    CTRL+/

    Toggle a comment on the current line

    SHIFT+ALT+A

    Add/remove a comment from the current selection





    CTRL+F2

    Rename all occurrences

    F2

    Rename a symbol within its validity





    CTRL+F

    Search in the script

    ENTER

    Find another occurrence

    SHIFT+ENTER

    Find the previous occurrence





    SHIFT+ALT+F

    Format the entire script

    CTRL+K CTRL+F

    Format the selected area





    CTRL+F12

    Go to definition

    CTRL+G

    Go to line

    ALT+F8

    Go to the next problem

    SHIFT+ALT+F8

    Go to the previous problem

    SHIFT+F12

    Go to references

    CTRL+SHIFT+O

    Go to symbol - displays the option to go to functions, variables, parameters defined in the script





    CTRL+SHIFT+F8

    Check script syntax

    CTRL+F8

    Compile the script

    CTRL+S

    Compile and save the script

    CTRL+1

    Opens a list of D2000 system objects.

    CTRL+2

    Opens a list of predefined constants.

    CTRL+3

    Opens a list of functions.

    CTRL+4

    Opens a list of actions.

    CTRL+5

    Opens a list of local variables.

    CTRL+6

    Opens a list of value attributes of an object or local variable.

    F8

    Switch to debug mode