Using Input Assistance

CODESYS provides tools and features to help you code when creating programs.

Input Assistant

The input assistant provides all program elements that you can insert at the current cursor position. Open the Input Assistant dialog box by clicking Edit ‣ Input Assistant or by pressing F2.

See also

AutoDeclare

This dialog box supports the declaration of variables.

See also

List Components

The “list components” function is an input tool in textual editors to help you input valid identifiers. Activate this function by selecting the List components after typing a dot (.) check box in Tools ‣ Options (SmartCoding category).

  • If you type a dot (.) instead of a global variable, then a drop-down list opens with all available global variables. You insert the selected variable after the dot by double-clicking a variable in the drop-down list or by pressing Enter.

  • If you type a dot (.) instead of a global variable after a function block instance variable or a structure variable, then CODESYS opens a drop-down list with all global variables, all input and output variables for the function block, or all structure components.

    You insert the selected variable after the dot by double-clicking a variable in the drop-down list or by pressing Enter.

    Please note: When you also want to choose from the local variables of function block instances, select the Show all instance variables in input assistant option in the CODESYS options (SmartCoding category).

  • When you type any sequence of characters and then press Ctrl+Space, a drop-down list opens with all available POUs and global variables. The first element in this list that starts with the sequence of characters is selected by default and you can insert it by double-clicking it or by pressing Enter.

  • CODESYS displays a tooltip if you type an opening parenthesis for a POU parameter when calling a function block, a method, or a function. This tooltip includes information about the parameters as they are declared in the POU. The tooltip remains open until you click to close it or you change the focus away from the current view. If you accidentally close the tooltip, then you can reopen it by pressing Ctrl+Shift+Space.

Note

You can use the 'hide' pragma attribute for excluding variables from the “list components” feature.

Examples

Typing structure variables:

list

Calling a function block:

See also

Short Form Feature

The short form feature allows you to type abbreviated forms for variable declarations in the declaration editor and in textual editors where variables declarations are possible. Use this feature by pressing Ctrl+Enter to end a declaration line.

CODESYS supports the following short forms:

  • All identifiers become variable identifiers except the last identifier of a line.
  • The data type of the declaration is determined by the last identifier of the line. The following applies:
    • B or BOOL yields BOOL
    • I or INT yields INT
    • R or BOOL yields BOOL
    • S or STRING yields STRING
  • If a data type is not defined using this rule, then the data type is automatically BOOL, and the last identifier is not used as the data type (see Example 1).
  • Depending on the type of declaration, every defined constant becomes an initialization or string length definition (see Example 2 and 3).
  • An address, such as %MD12, is automatically extended with the AT attribute (see Example 4).
  • Any text after a semicolon (;) is converted into a comment (see Example 3).
  • All other characters in the line are ignored (see exclamation mark in Example 5).

Examples

Example Short Form Resulting Declaration
1 A A: BOOL
2 A B I 2 A, B: INT := 2;
3 ST S 2; A string ST:STRING(2); (* A string *)
4 X %MD12 R 5 Real Number X AT %MD12: REAL := 5.0;(* Real Number *)
5 B ! B: BOOL

See also