Declaration Editor

In the declaration editor, you declare variables in variable lists and POUs.

If the declaration editor is used in conjunction with a programming language editor, it opens in a window above the programming language editor.

The declaration editor offers two possible views: textual(Declaration Editor 1:) and tabular(Declaration Editor 2:). In the dialog Tools > Options > TwinCAT > PLC Environment > Declaration editor you can define whether either only the text-based view or only the tabular view is available, or whether the user can choose between the two views via the buttons on the right of the editor window.

Rectangle selection is possible in the textual view of the declaration editor. The shortcuts for the rectangle selection can be found in the chapter ST Editor.

Text-based declaration editor

You configure the behavior and appearance of the text editor with the settings in the dialog Tools > Options > TwinCAT > PLC Environment > Text editor. The settings concern colors, line numbers, tab widths, indentations, etc. The normal Windows functions and, if applicable, the IntelliMouse functions are available in the text editor.

You can also use comments in the textual declaration editor (see ST comments).

Declaration Editor 3:

Tabular declaration editor

In the tabular declaration editor, you insert variable declarations in a table with the following columns: scope, name, address, data type, initialization, comment and (pragma) attributes.

Declaration Editor 4:

Declaration editor in online mode

In online mode, you see the tabular view of the editor. The header always contains the current object path: <device name>.<project name>.<object name>. As opposed to offline mode, the table also contains the columns Value and Prepared value.

Value

Shows the actual value on the controller, thus provides monitoring functionality.

If the expression is an array with more than 1000 elements, you can specify the range of the array indices to be monitored. To do this, double-click in the column Data type to open the dialog Monitoring area. In this dialog, the declared array range is entered as the Valid range for monitoring. A maximum of 20000 elements can be displayed per array.

You define the range of array indices to be displayed by specifying the start and end index. To move this area more easily while keeping the scope constant, you can use the scrollbars coupled for this purpose. To switch between linked scrollbars Declaration Editor 5: and unlinked scrollbars Declaration Editor 6: click the icon to the right of the bars. In the uncoupled state, you can increase or decrease the scope of the area to be displayed as you wish.

Prepared value

Contains the value you may have prepared for forcing or writing.

If you double-click a field in the column Prepared value, you can directly enter a value for writing or forcing.

For enumerations a combo box opens, from which you can select a value.

With a boolean variable you can toggle (switchover) the prepared value with the help of the [Enter] or [Space] key.

If an expression (variable) is of a structured data type, for example the instance of a function block or an array variable, then it is preceded by a plus or minus sign.

You can adjust the format of the representation of floating-point numbers as well as the representation of the inheritance hierarchy in the context menu.

See also: