消息
Using ‘THIS’ is not allowed in this context
错误原因
如要分配到实例,THIS 只能用在方法、操作和转换中,或者用在功能块的主体中。所有其他位置也会显示此错误消息。
错误示例
PROGRAM PLC_PRG
VAR
test1: INT;
END_VAR
THIS^.test1 := 19;
--> C0018: 'THIS^.test1' is not a valid assignment target
--> C0062: 'THIS^' is not a structure variable
--> C0045: Using 'THIS' is not allowed in this context