Function object with plc code
A function object, where the code is written in plc-code in the plc editor, is defined in a
similar way as the function object with c-code above.
The functionobject class is defined by a $ClassDef object below the 'Class' object. Name the
object and activate Configure-Fo in the popupmenu for the object. Now, in addition to the
objects created for the c-code functionobject, also a Code object of class PlcTemplate is
created. This object can be opened with the plc editor, and define the code for the class.
Inputs, intern attributes and outputs in the function object are defined in the same way as for
the c-code function object, by $Input, $Intern and $Output attributes.

Definition of a function object with plc code.
Code
By activating 'Open Program...' in the popupmenu of the Code object, the plc editor is opened.
Here the code is written with function object programming. The code is created similar to an
ordinary program, but here you also have to fetch values from the input and intern attribute,
and to set values to the outputs.
Values of inputs, intern attributes, and also outputs, are fetched in the code with GetDp,
GetIp, GetAp or GetSp objects. You connect the objects to attributes in the class by
selecting the attribute in the Template object for the class, and activate the 'Connect'
method for the Get object. A symbolic reference $PlcFo is put into the Get object. This will
later be exchanged to a reference to the current instance, when the code for the instance is
compiled.
Calculated values are stored in outputs or intern attributes with StoDp, StoIp etc. These are
connected to attributes in the same way as the inputs, by selecting the attributes in the
Template object and activating 'Connect'.

Example of plc code for a function object
The template code in the Code object should not be compiled or built. When an instance object
is compiled for the first time, the template code is copied to the instance.
When the template code is changed, the code of the instances will be updated the next time
they are compiled (the volume containing the instances, has to be updated with UpdateClasses
first).