Command: Refactoring – Add Variable
Symbol:
Function: The command allows for the declaration of variables in a POU, as well as the automatic update to the occurrence locations of the POU.
Call: menu; context menu
Requirement: The declaration part is in focus.
The command opens the default dialog for declaring variables.
Dialog: Refactoring
After clicking OK to close the declaration dialog, the Refactoring dialog opens with two frames.

Right dialog frame | Declaration part and implementation of the POU where the variable is added Highlighting of changed locations: Recently added declarations in blue font and highlighted in yellow (1) |
Left dialog frame | Device tree or POU tree of the project Highlighting of blocks where the POU is used: red font and highlighted in yellow (2) After you double-click the POU object, the detail view opens. |
Before you decide which changes to accept at which locations, select the required option from the list box (3) at the upper right part of the window:
Add inputs with placeholder text | Default placeholder text
The placeholder text defined here is used at the occurrence locations of the new added variables in the implementation code. This is used for searching for the relevant locations. |
Add inputs with the following value | Initialization value for the new variable |
You can accept or reject changes by right-clicking the changed locations or by executing commands in the left or right area of the dialog. For more information, see also the description for the
command.By refactoring, the
fun
block gets a new input variableinput3
with the initialization value1
.The change has the following impact:
Before:
fun(a + b, 3, TRUE); fun(input1:= a + b , input2 :=3 , inputx := TRUE);
After:
fun(a + b, 3, 1, TRUE); fun(input1:= a + b , input2 :=3 , _REFACTOR_, inputx := TRUE);
By refactoring, the
fun
block gets a new input variableinput3
with the_REFACTOR_
placeholder text.
Before:
inst(input1 := a + b, input2 := 3, inputx := TRUE); fun(a + b, 3, TRUE);
After:
inst(input1 := a + b, input2 := 3, input3 := _REFACTOR_, inputx := TRUE); fun(a + b, 3, _REFACTOR_, TRUE);
For more information, see: Refactoring