Attention

IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include arrays and structures. Try it out in the IronPLC Playground.

P4020

Code

P4020

Message

Source does not contain a PROGRAM declaration

This error occurs when the compiler cannot find a PROGRAM declaration in the source. At least one PROGRAM is required to compile and run.

Example

The following code will generate error P4020:

FUNCTION_BLOCK my_fb
VAR
    x : INT;
END_VAR
    x := 1;
END_FUNCTION_BLOCK

The source defines a function block but does not contain a PROGRAM declaration, so the compiler has no entry point.

To fix this error, add a PROGRAM declaration:

FUNCTION_BLOCK my_fb
VAR
    x : INT;
END_VAR
    x := 1;
END_FUNCTION_BLOCK

PROGRAM main
VAR
    fb_inst : my_fb;
END_VAR
    fb_inst();
END_PROGRAM