EXTENDS

EXTENDS derives a function block type from a single base type, so the derived type inherits the base type’s variables (and, once supported, its methods). It also derives an interface from one or more base interfaces. This is the inheritance mechanism introduced in IEC 61131-3 Edition 3.

Note

EXTENDS is a keyword only when the --allow-fb-inheritance flag is enabled. When the flag is not set, EXTENDS is an ordinary identifier and may be used as a variable or type name, exactly as in standard IEC 61131-3. Pass --allow-fb-inheritance to enable the object-oriented syntax, or select a dialect that includes it. See Enabling Dialects and Features for the dialects and flags reference.

IEC 61131-3

Edition 3 (object-oriented programming)

Support

Parsed only — not yet analyzed or executed (P9999). Enable with --allow-fb-inheritance; see Enabling Dialects and Features.

Syntax

On a function block declaration, EXTENDS names the single base type:

FUNCTION_BLOCK derived_name EXTENDS base_name
    variable_declarations
    statement_list
END_FUNCTION_BLOCK

On an INTERFACE declaration, EXTENDS names one or more base interfaces, separated by commas:

INTERFACE interface_name EXTENDS base_interface {, base_interface}
END_INTERFACE

Example

FUNCTION_BLOCK FB_Motor
    VAR
        running : BOOL;
    END_VAR
END_FUNCTION_BLOCK

FUNCTION_BLOCK FB_AdvancedMotor EXTENDS FB_Motor
    VAR
        speed : INT;
    END_VAR
END_FUNCTION_BLOCK

FB_AdvancedMotor is the derived type and FB_Motor is its base type. A function block type extends at most one base type.

See Also