Methods of FBs in PLCnext Engineer
General information on FB methods
PLCnext Engineer supports object-oriented programming for function blocks by using methods. By adding a method to a user-defined function block POU, the function block is defined as an object-oriented function block.
Note
Safety-related object-oriented function blocks are not supported. This means, no methods can be added to safety-related FBs. |
Similar to function POUs, methods do have a result type, a variable declaration part and one or more code worksheets.
For each method an access specifier must be specified. This access specifier defines from where the method may be called.- 'Public': the method can be called from anywhere where it can be used (internal and external calls).
- 'Private': the method can only be called from inside the POU where the method is defined (internal calls only).
Access specifier and the data type of the return value have to be specified in the 'Settings' editor (see figure below).
To add a method to a user-defined function block POU, right-click the function block POU under 'COMPONENTS | Programming > Local > Functions & Function Blocks' (or any subfolder) and select the context-menu command 'Add Method'.
Method call
Methods can be called in the textual language ST and the graphical languages FBD/LD, NOLD and SFC either internally or externally (depending on the access specifier).
Note
In all languages, entering the method call is supported by the Intellisense ![]() ×‣ Intellisense in the Graphic Editor × function. |
Internal call of a method
Internal calls are possible for methods with the access specifier 'Public' and 'Private'. Internal means, the method is called in the user-defined function block POU where it is defined.
In ST, the method name must be preceded by the keyword 'THIS' followed by a dot. Even if no parameters are required, it must end with parentheses "()".
In FBD/LD/NOLD/SFC, you have to enter the instance name "THIS" for an inserted internal method. The keyword "THIS" is then indicated above the block symbol. The FB POU name and the method name separated by a dot are shown within the symbol.
Internal method call in ST | ![]() |
Internal method call in FBD/LD/NOLD | ![]() |
External call of a method
External calls are only possible for methods with the access specifier 'Public'. External means, the method is called from another POU (program or FB).
For the external method call, the instance name of the function block which contains the method must be included in the call. Therefore, this FB instance name must be declared in the variables table of the calling POU.
In ST, the method name must be preceded by the FB instance name followed by a dot. Even if no parameters are required, it must end with parentheses "()".
In FBD/LD/NOLD/SFC, you have to enter or select the already declared FB instance name for the inserted external method. The FB instance name is then indicated above the block symbol. Inside the symbol, the FB name which contains the method precedes the method name, separated by a dot.
Instance declaration of the FB containing the method in the variables table of the calling POU | ![]() |
External method call in ST | ![]() |
External method call in FBD/LD/NOLD | ![]() |