Creating a Function Block in Control Builder F
Voted best answer
First you need to create a function block class in the project tree.
The P-UFB node holds all the UFBs for a project. Below it you create your UFB class Object, "LED_CTRL" in this picture. The class contains the Interface definition which contains Inputs, Outputs and Parameter for the UFB. The program of the UFB is created under the FB-CLASS object, LED_CTRL_P in this case.
You need to plausibility check the class, before you can use it in a program!
Here is, how you would use your UFB in another ST program.
First you need to instantiate your UFB. This is done in the VAR statement. See upper arrow.
Then in the program body you call your UFB providing Inputs and Outputs. Please note, that while in the interface definition (in the FB-CLASS object) Inputs and Outputs can have 16 character names, invoking a UFB allows you only to use the first 3 letters of those inputs and outputs. So the names needs to be chosen wisely to always differ in the first 3 characters.
A good source for learning about UFBs is the "Engineering Manual IEC 61131-3 Programming", section 10 "User Function Blocks"