Function: The command opens the “Extract Function Configuration” dialog.
The command extracts selected code from the ST editor and creates a new method or function containing this code. The affected code in the ST editor is replaced by a correct call. When code is extracted from a function block or the child of a function block, a new method is created from the code. When code is extracted from a program or a function, a new function is created from the code.
Call: Context menu: “Refactoring”
Requirements: When the selected code consists of one or more statements:
-
The selected code does not contain any compile errors.
-
The selected code is located in the implementation part of an ST POU.
-
The selected code does not contain any exiting jumps
Examples of exiting jumps include the following:
-
Using
RETURN
to exit the enclosing function -
Using
CONTINUE
orEXIT
to exit a loop enclosing the code
-
You can undo the changes that the “Extract function” command made in your project by positioning the cursor in the device tree and clicking “Edit Undo”.
“Name” |
Name of the recently created function or method The default name can be changed. |
“Return value” |
Determines the return value of a function if there are multiple output and/or input/output parameters |
“Parameter” |
Display of the available POUs Configuration whether the parameters are used as input, output, or input/output variables
|
|
The changes made for “Name”, “Return value”, or “Parameter” are undone. |
Upper code window |
Recently created code of the call location |
Lower code window |
Recently created code of the function or method |
“OK” |
The displayed code changes are accepted in the ST POUs and the dialog is closed. |
“Cancel” |
The displayed code changes are rejected and the dialog is closed. |