P4084¶
- Code
P4084
- Message
Field is not declared on the structure or function block or any function block in its EXTENDS chain
This error occurs when a field selection, such as pump.speed, names a field
that the type of the variable does not have.
The fields of a structure are the ones its STRUCT declares. The fields of a
function block instance are the block’s VAR_INPUT, VAR_OUTPUT,
VAR_IN_OUT and VAR variables, including those it inherits through
EXTENDS. A property of the function block is not reported by this error.
Example¶
The following code will generate error P4084:
TYPE
Motor : STRUCT
speed : INT;
running : BOOL;
END_STRUCT;
END_TYPE
PROGRAM main
VAR
pump : Motor;
END_VAR
pump.sped := 100; (* Error: Motor has no field sped *)
END_PROGRAM
The structure Motor has the fields speed and running, so sped
names nothing. When the name is close to a field’s name, the compiler suggests
that field.
To fix this error, select a field the type declares:
TYPE
Motor : STRUCT
speed : INT;
running : BOOL;
END_STRUCT;
END_TYPE
PROGRAM main
VAR
pump : Motor;
END_VAR
pump.speed := 100;
END_PROGRAM
See Also¶
Structure Types — declaring the fields of a structure
FUNCTION_BLOCK — the inputs and outputs of a function block
EXTENDS — fields a function block inherits
P4007 — a variable that is not declared
P4046 — a method that is not declared
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.