206 5 Standardised PLC Functionality
5.1.1 Overloaded and extensible functions
The data types of the input variables are given in round brackets next to the
function names in Table 5.1. Here generic data types, already introduced in Table
3.9, are also given for reasons of clarity. Each function whose input variable is
described using a generic data type is called overloaded and has a “yes” in the
corresponding column in Table 5.1. This simply means that the function is not
restricted to a single data type for its input variables, but can be applied to
different data types.
The data type of the function value (2
nd
column) is normally the same as the data
type of its inputs. Exceptions are functions such as LEN, which expects a character
string as its input but returns INT as its function value.
If a standard function can have a variable number of inputs (2, 3, 4,...), it is called
extensible. Such functions have a “yes” in the corresponding column in Table 5.1.
No formal parameters have to be entered when calling extensible functions. In
textual languages they are called simply by using actual parameters separated by
commas – in graphical representation the parameter names inside the boxes are
omitted.
In IEC 61131-3 these properties are not applied to user-defined functions, but can
also be extended to these functions (and other POU types) as a supplement to the
standard, depending on the programming system.
Overloading and extensibility of standard functions is explained with the use of
examples in the next two sections.
Overloaded functions
Overloaded functions can be applied for processing several data types using only
one function name.
An overloaded function does not always support every data type of a generic
data type, as explained in Chapter 3.
For example, if a PLC programming system recognises the integer data types INT,
DINT and SINT, only these three data types will be accepted for an overloaded
function ADD which supports the generic data type ANY_INT.
If a standard function is not overloaded, but restricted to a certain elementary
data type, an underline character and the relevant data type must be added to its
name: e.g. ADD_SINT is an addition function restricted to data type SINT. Such
functions are called typed. Overloaded functions can also be referred to as type-
independent.
This is illustrated in Example 5.1 using integer addition: