P4046¶
- Code
P4046
- Message
Method is not declared on the function block or any function block in its EXTENDS chain
This error occurs when a method call (instance.MethodName(args),
part of IEC 61131-3 Edition 3’s OOP extension) refers to a method that
is not declared on the instance’s function block type, nor on any
function block reached by following that type’s EXTENDS chain.
Example¶
The following code will generate error P4046:
FUNCTION_BLOCK FB_Motor
VAR
bRunning : BOOL;
END_VAR
END_FUNCTION_BLOCK
PROGRAM main
VAR
m : FB_Motor;
END_VAR
m.Start();
END_PROGRAM
To fix this error, declare the method on the function block (or on a
base function block it EXTENDS):
FUNCTION_BLOCK FB_Motor
VAR
bRunning : BOOL;
END_VAR
METHOD Start
bRunning := TRUE;
END_METHOD
END_FUNCTION_BLOCK
PROGRAM main
VAR
m : FB_Motor;
END_VAR
m.Start();
END_PROGRAM
Think IronPLC is wrong about this?
If you believe this diagnostic is incorrect, open an issue on GitHub with a small sample that demonstrates the problem.