INTERFACE |
Top Previous Next |
Using the INTERFACE / IMPLEMENTATION functionality it is possible to split a FUNCTION and FUNCTION_BLOCK into two sections. One section that caters for the interface and another section that caters for the actual implementation.
Using this separation it is possible to expose the interface in a separate INC file and then the implementation can be in another INC file that may be encrypted.
Another advantage with this separation is to break dependencies in large program complexes, such that as soon as the INTERFACE has been declared, then other parts of the code can reference the function / function block.
Example of usage:
FUNCTION INTERFACE funcA:INT VAR_INPUT a : INT; b : DOUBLE; END_VAR; // Notice that no local variables are allowed in the interface section. END_FUNCTION;
FUNCTION testA; VAR p : INT; END_VAR;
//This function references funcA, where only the interface is defined. p := funcA(a := 10,b := 27.14);
END_FUNCTION;
FUNCTION IMPLEMENTATION funcA; // return value cannot be specified here. //No VAR_INPUT is allowed here. VAR aaa : INT; //Local variables are allowed here. END_VAR;
END_FUNCTION;
|