If the Autodeclaration option has been chosen in the Editor category of the Options dialog box , then a dialog box will appear in all editors after the input of a variable that has not yet been declared:
With the help of this dialog box, the variable can now be declared.
With the help of the Class combobox, select whether you are dealing with a local variable (VAR), input variable( (VAR_INPUT), output variable (VAR_OUTPUT), input/output variable (VAR_INOUT), or a global variable (VAR_GLOBAL).
With the CONSTANT, RETAIN, PERSISTENT options, you can define whether you are dealing with a constant or a retain variable .
The variable name you entered in the editor has been entered in the Name field, BOOL has been placed in the Type field. [...] opens the input assistant dialog which allows you to select from all possible data types.
Declaration of Arrays
If ARRAY is chosen as the variable type, the dialog for entering array boundaries appears:
For each of the three possible dimensions (Dim.), array boundaries can be entered under Start and End by clicking with the mouse on the corresponding field to open an editing space. The array data type is entered in the Type field. In doing this, [...] can be used to call up an input assistant dialog.
Upon leaving the array boundaries dialog via the OK button, variable declarations in IEC format are set up based on the entries in the Type field in the dialog. Example: ARRAY [1..5, 1..3] OF INT
In the field Initial value, you may enter the initial value of the variable being declared. If this is an array or a valid structure, you can open a special initialization dialog via [...] or <F2>, or open the input assistant dialog for other variable types.
In the initialization dialog for an array you are presented a list of array elements; a mouse click on the space following ":="opens an editing field for entering the initial value of an element.
In the initialization dialog for a structure, individual components are displayed in a tree structure. The type and default initial value appear in brackets after the variable name; each is followed by ":=". A mouse click on the field following ":=" opens an editing field in which you can enter the desired initial value. If the component is an array, then the display of individual fields in the array can be expanded by a mouse click on the plus sign before the array name and the fields can be edited with initial values.
After leaving the initialization dialog with OK, the initialization of the array or the structure appears in the field Initial value of the declaration dialog in IEC format.
Example: x:=5,field:=2,3,struct2:=(a:=2,b:=3)
In the Address field, you can bind the variable being declared to an IEC address (AT declaration).
If applicable, enter a Comment. The comment can be formatted with line breaks by using the key combination <Ctrl> + <Enter>.
By pressing OK, the declaration dialog is closed and the variable is entered in the corresponding declaration editor in accordance to the IEC syntax.
The dialog box for variable declaration you also get by the command 'Edit' 'Declare Variable'⮫ “'Edit' 'Autodeclare'”. If the cursor is resting on a variable in Online mode, the Autodeclare window can be opened with <Shift><F2> with the current variable-related settings displayed.