About the Script editor

You use the Script editor to code functions and events, define your own functions and events, and declare variables and external functions.

Script editor is part of the default layout in the Application, Window, User Object, Menu, and Function painters. In Application, Window, and User Object painters, the initial layout has one Script editor that displays the default event script for the object and a second Script editor set up for declaring instance variables. You can open as many Script editors as you need, or perform all coding tasks in a single Script editor.

Title bar

The Script editor's title bar (①) shows the name and return type of the current event or function, as well as the name of the current control for events and the argument list for functions. If the Script editor is being used to declare variables or functions, the title bar shows the type of declaration.

Status bar

The status bar (②) displays at the bottom of the editor.

A zooming slider displays at the bottom left corner to allow users to adjust the text size, and line and column numbers displays at the bottom right corner.

Navigation drop-down lists

There are three drop-down lists (③) at the top of the Script editor, to help you navigate the code easily:


In the first list, you can select the object, control, or menu item for which you want to write a script. You can also select Functions to edit function scripts or Declare to declare variables and external functions.

The second list lets you select the event or function you want to edit or the kind of declaration you want to make. A script icon next to an event name indicates there is a script for that event, and the icon's appearance tells you more about the script:

If there is a script

The script icon displays

For the current object or control

With text ()

In an ancestor object or control only

In color ()

In an ancestor as well as in the object or control you are working with

Half in color ()


The same script icons display in the Event List view.

The third list is available in descendant objects. It lists the current object and all its ancestors so that you can view scripts in the ancestor objects.

Toggle buttons for Prototype and Error windows

A Prototype window displays at the top of the Script editor when you define a new function or event. An Error window displays at the bottom of the view when there are compilation errors. You can toggle the display of these windows with the two toggle buttons to the right of the lists (④).


For more information about the Prototype window, see Working with User-Defined Functions and Working with User Events.

Line numbers

Line numbers are enabled by default and displayed in the left margin of the editor. To disable line numbers, go to Design menu > Options menu > Script tab page, and disable the Display line numbers option.

Syntax coloring

Different code elements such as function name, variable name, class name etc. appear in different colors. You can enable/disable this feature and configure the colors in the Design menu > Options menu > Coloring tab page.

Highlight current line

The current line where the cursor is located is highlighted with a grey box, and the line number displays in a different color. This feature can be turned off in the Design menu > Options menu > Script tab page.


When you click on a code element (such as keyword, variable name, method name, etc.), all instances of that element are highlighted.


Bracket matching

Placing the cursor to the left of an open bracket, or to the right of a closing bracket, will automatically highlight the bracket pair. This allows you to find out which brackets are misplaced or missing.


Change tracking

Changes you have made since the file was opened are indicated by color marker in the left margin of the editor. The changes are indicated by yellow marker before saved; and indicated by green marker after saved.


Rectangular selection

You can select a rectangular area of code or text by holding the Alt key and dragging the mouse over the selection (or pressing Alt+Shift+<arrow key>). The selection includes all characters within the rectangle defined by the first character and the last character in the selection. Anything typed or pasted into the selected area is inserted at the same point on each line.


Multi-cursor editing

You can edit the text at multiple locations (multi-cursors) at the same time. To do this, hold down the Ctrl key and use the mouse to click multiple locations to insert the cursor or select multiple text locations and edit the text.


Outlining & folding

Syntax statements like FOR...NEXT, IF...ENDIF, CHOOSE CASE, DO...LOOP, TRY...CATCH etc. and /*...*/ can be displayed in the outlining & folding view.

Click the minus symbol in front of the statement to fold the code. When the syntax is folded into one line, an ellipse (...) symbol will display at the end of the line; when you hover the mouse over symbol, you can view the folded code.


Word wrapping

Text can be automatically wrapped and displayed on the next line when it exceeds the editor's width, and a wrap symbol appears after the line breaks. This feature can be turned off in the Design menu > Options menu > Script tab page.


View white space

White spaces can be set to visible in code. Spaces will display as dots and tabs will display as arrows. This feature can be turned on in the Design menu > Options menu > Script tab page.


Horizontal whitespace removal

You can remove extra or unnecessary spaces and tabs that appear between elements in a single line of code, via the right-click menu: Code Formatting > Delete Horizontal White Space.

Line indentation

You can enable/disable auto indenting inside statements such as IF, FOR etc. in the Design menu > Options menu > Script tab page.

You can also increases or decreases line indentation via the right-click menu: Code Formatting > Increase Line Indent or Decrease Line Indent.

Case conversion

You can convert the case of selected text via the right-click menu: Code Formatting > Make Uppercase or Make Lowercase.

Comments

You can add comment characters to the selected line, or to the current line if no characters are selected, or remove comment characters, via the right-click menu: Code Formatting > Comment Selection or Uncomment Selection.

Code auto completion

Code auto completion offers all possible options alphabetically as you type the trigger characters in the script editor, and highlights the option that best matches the trigger characters. You can choose to display one or more types of code via the icons at the bottom of the list, such as function, event, variable, code snippet, class, keyword etc. For more information, refer to Using AutoScript.

Parameter info help

When you you type a method name followed by the parameter bracket "(", you can directly activate the parameter information help for that method. For more information, refer to Using Parameter Info.

QuickInfo help

When you hover over a variable, method etc. with the mouse pointer, the detailed information for that item will be displayed. For more information, refer to Using QuickInfo.

Add breakpoints

When you click the gray bar at the beginning of a line, a red circle will appear indicating a breakpoint is added for that line. And you can remove the breakpoint by clicking on the red circle. For more information, refer to Setting breakpoints.

Note

Mosts of the above features are also available in the source editor opened from the Edit Source pop-up menu in the system tree.