Command ‘Auto Declare’

Shortcut: Shift+F2

Function: The command opens the dialog box Auto Declare, which supports the declaration of a variable.

Call: Main menu Edit

Requirement: An object or a device of the project is opened in the editor.

Due to the auto-declaration function, the dialog box Auto Declare also appears when the cursor is located in the implementation part of a POU in a line containing the name of an undeclared variable. The requirement for this is that you must have selected the command Tools ‣ Options and activated the option Declare unknown variables automatically (AutorDeclare) in the category SmartCoding.

Dialog Box ‘Auto Declare’

Scope

Selection list for the scope of the variables.

By default VAR (local variable) is shown here.

Name Empty input field or name of the as yet undeclared variable as you entered it in the POU.
Type
  • Selection list with all available data types.
  • 36a21027ccec5d5fc0a8640e01ff1fb3_2514dabdcd1da22ac0a8640e017603ee
    • Input Assistant: opens the dialog box Input assistant
    • Array Wizard: opens the dialog box Arrak
Object

Selection list for the definition of the object in which you declare the variable.

By default the object that you are presently editing is shown here.

If no objects are available for the selected Scope, the entry <create object> appears. If you select the entry <create object>, the dialog box Add object appears for the generation of a suitable object.

Initialization

If you do not enter an initialization value, CODESYS initializes the variable with the default value.

36a21027ccec5d5fc0a8640e01ff1fb3_21d51bd0cd4519c1c0a8640e00abb4b7 : opens the dialog box Initialization value. This procedure is recommended for the initialization of structured variables.

Address CODESYS binds a variable to an IEC address.
Flags

Definition of the attribute keywords

  • CONSTANT: constant
  • RETAIN: remanent variable
  • PERSISTENT: remanent variable (stricter than RETAIN)

CODESYS adds the selected attribute keyword to the variable declaration.

Comment In the tabular declaration editor the comment entered is displayed in the column Comment, while in the textual declaration editor it is displayed above the variable declaration.

Dialog Box ‘Array’

Ranks and base type specification Definition of the field sizes (Dimension) by entering the lower and upper limits and the Basic Type of the array. You can enter the basic type directly or with the help of the dialog boxes Input assistant or Array if you click on the button 36a21027ccec5d5fc0a8640e01ff1fb3_2514dabdcd1da22ac0a8640e017603ee .
Result display of the defined array.

Attention

CODESYS only re-initializes variables if you have modified the initialization values of the variables.

Dialog box ‘Initialization value’

List of the variables with name (Expression), Init value and Data type.

Modified initialization values are displayed in bold lettering.

Input field below the list Input of an initialization value for the selected variable(s).
Apply value to selected lines Change of the initialization value of the selected line(s) according to the value of the input field.
Reset selected lines to default values Establishment of the standard initialization values.
OK CODESYS adopts the initialization values in the dialog box Declare variable.

See also