Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

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