Structure of program elements

Each new statement/declaration should start on a new line.

The following section explains the structuring of program elements (including POUs, DUTs, GVLs) using text blocks, text sections and text regions.

Text blocks

Text sections

Text regions

Sample

There are 2 text regions ("Drill settings" and "Conveyor settings") with 2 text sections ("Positions" and "Velocities"). In the text region "Drill settings", the text section "Velocities" consists of 2 text blocks (thematically related associations and an IF statement).

Program code:

//=========================================================
// Drill settings

    // Positions
    fbDrill.nPositionLower  := 100;
    fbDrill.nPositionTop    := 500;

    // Velocities
    fbDrill.fVelocityRated  := 40.0;
    fbDrill.fVelocityMax    := 100.0;

    IF fbDrill.fVelocityAverage > fbDrill.fVelocityRated THEN
        bWarning := TRUE;
        sWarning := 'Drill velocity: Average exceeded rated';
    END_IF

//=========================================================
// Conveyor settings

    // Positions
    fbConveyor.nPositionFilling    := 50;
    fbConveyor.nPositionDrill      := 200;
    fbConveyor.nPositionDischarge  := 300;

    // Velocities
    fbConveyor.fVelocityRated      := 75.5;

//=========================================================

Expanded text regions:

Structure of program elements 1:

 

Collapsed text regions:

Structure of program elements 2:

 

See also: