Declaration of a function in ST
FUNCTION name (* optional_begin *) : data-type (* optional_end *)
( * optional_begin *) USING Namespace_1;
USING Namespace_2; (* optional_end *)
(* optional: declaration of variables *)
(* optional: body of function *)
END_FUNCTION
Meaning |
declaration of a →function, name must be an →IEC-identifier.
The data type
: data-type
is optional but is required if a return value is assigned within the function (see example "
Assigning return value within a function"
) or the function is used as operand.
The USING namespace directive after the name or the data type of the function is optional. See "Namespaces in ST: usage" for details on this directive. |
FUNCTION Simple1
END_FUNCTION
FUNCTION Simple2 : INT
END_FUNCTION
You are able to use the following language elements for ST within a function:
Page:Read-only statement
Page:CASE statement in ST
Page:EXIT statement in ST
Page:FOR statement in ST
Page:IF statement in ST
Page:Comments in ST
Page:Assignments in ST
The usage of these language elements makes it possible to use other elements (e.g. declaration of STRING variables within the section VAR ... END_VAR ) as well. Such elements are not listed here.