Compiler Error C0045

Message: Use of 'THIS' is not allowed in this context.

Possible error cause: In order to be assigned to the current instance, THIS can be used only in a method, action, transition, or in the body of a function block. This error message appears for all other positions.

Error correction: Use THIS in an allowed context only.

Example of the error:

PROGRAM MAIN
VAR
    test1: INT;
END_VAR

THIS^.test1 := 19;

Message:

Use of 'THIS' is not allowed in this context.