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
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 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 |
|
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.
|
Address | CODESYS binds a variable to an IEC address. |
Flags | Definition of the attribute keywords
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 ![]() |
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