Using the input wizard

TwinCAT offers functionalities and wizards that facilitate code input during programming.


Dialog Input Assistant

The dialog offers all programming elements, which you can add at the current cursor position. You can open the Input Assistant dialog with the command Input Assistant in the Edit menu, from the context menu, or with the keyboard shortcut [F2].

See also:

TC3 User Interface documentation: Command Input Assistant

Dialog Auto Declare

A dialog provides support for declaring variables. Open the dialog Auto Declare with the Auto Declare command in the Edit menu or via the context menu.

See also:

TC3 User Interface documentation: Command Auto Declare

List components

The function List components is an input support feature in the text editor, which facilitates entering valid identifiers. The function can be enabled as follows: Select the command Options in the Tools menu and then the category TwinCAT > PLC Environment > Smart coding. Enable the option List components after typing a dot (.).

If you then enter a dot . instead of global variable, a selection list with all available global variables appears. Double-click on a variable in the selection list or press the [Enter] key to add the selected variable after the dot.
If you enter a dot instead of a global variable or after a function block-instance variable or a structure variable, TwinCAT shows a corresponding selection list all global variables, all input and output variables of the function block or all structure components.
Double-click on a variable in the selection list or press the [Enter] key to add the selected variable after the dot.
If you also want to see the local variables of function block instances, in the TwinCAT options for smart coding enable the option List all instance variables in the input assistant.
If you enter any string and then press [Ctrl] + [space bar], a selection list appears with all available POUs and global variables. The first element in this list, which starts with the previously entered string, is automatically selected, and you can enter it in the editor by double-clicking or via the [Enter] key.
If you call a function block, a method or a function and enter a left parenthesis for entering the POU parameters, TwinCAT shows a tooltip. This tooltip contains information on the parameters, as they are declared within the POU. The tooltip remains visible until you close it with a mouse click or by placing the focus outside the current view. If you close the tooltip accidentally, you can open it again with [Ctrl] + [shift key] + [space bar].
The pragma attribute 'hide' can be used to exclude variables from List components function. (Attribute 'hide')


Entering a structure variables:

Calling a function block:


Shortcut mode

Shortcut mode enables entering shortcuts for the variable declaration in the declaration editor and in the text editors, in which variable declarations are possible. You can enable this mode by ending a declaration line with the key combination [Ctrl] + [Enter].

TwinCAT supports the following shortcuts:

All identifiers apart from the last identifier in a line become variable identifiers of a declaration.
The data type of the declaration is determined by the last identifier in the line. The following applies:
B or BOOL results in BOOL
I or INT results in INT
R or BOOL results in BOOL
S or STRING results in STRING
If no data type is specified based on these rules, the data type is automatically set to BOOL, and the last identifier is not used as data type (see example 1).
Each constant that is entered is interpreted as an initialization or a string length declaration, depending on the type of declaration (see examples 2 and 3)
An address (such as in %MD12) is automatically extended with the AT attribute (see example 4)
Text after a semicolon ; is interpreted as a comment (see example 3)
All other characters in the line are ignored (see exclamation mark in example 5)


resulting declaration
nA nB I 2
nA, nB: INT := 2;
sC S 2; C string
sC: STRING(2); // C string
X %MD12 R 5
X AT %MD12: REAL := 5.0;
bE !

See also:

Declaring variables
TC3 User Interface documentation: Dialog Options - Smart coding