Methods FB_init, FB_reinit and FB_exit
You can use the methods explicitly to influence the initialization of function block variables and the behavior when function blocks are terminated.
Refer also to the information on the different operating cases and the behavior of these methods with derived function blocks.
The type of return value for the implicit methods is BOOL. The return type should not be changed even if the value is not evaluated. Do not add any output variables to the methods. You can only define additional input variables. |
Explicit calling is not recommended The methods FB_init, FB_reinit and FB_exit are system functions that are called implicitly at different times (further information on this can be found under Operating cases). Explicitly calling these methods can have inadvertent consequences and is therefore not recommended. |
Automatic core dump on exception in FB_init/FB_reinit/FB_exit If an exception error occurs within the FB_init/FB_reinit/FB_exit code, e.g. due to a programming error, the runtime system automatically stores a core dump on the target system (from TC3.1 Build 4024.25). This core dump is stored as a *.core file in the boot folder of the target system (by default under C:\TwinCAT\3.1\Boot\Plc) and can be used for the search of causes. For more information on loading a core dump, see: Error analysis with core dump |
Add methods
- 1. Select a function block in the PLC project tree in the Solution Explorer.
- 2. In the context menu select the command Add > Method...
- The dialog Add Method opens.
- 3. Open the drop-down list in the field for naming the method.
- 4. Select one of the methods FB_init, FB_reinit or FB_exit.
- 5. Click on Open.
- The method is added to the PLC project tree and opened in the editor. The definition of the method (return value, parameter) takes place automatically.
Return value
Implicit calls
If the methods are called implicitly the return value will not be evaluated by the system. Even if you adjust the return value, it will not be evaluated with an implicit call.
Explicit calls
If the methods are called explicitly you can evaluate the return value. You can thus return a meaningful return value.
See also:
- Object Method
- Attribute 'call_after_init'
- Attribute 'call_after_online_change_slot'
- Attribute 'call_on_type_change'
- Attribute 'no_copy'
- Attribute 'no-exit'