Programming Industrial Control Systems Using IEC 1131-3, Revised Edition

This chapter describes Structured Text, a high level textual language, which is the first of the IEC languages in the set:
Structured Text, Function Block Diagram, Ladder Diagram, Instruction List and Sequential Function Chart.
Structured Text or ST can be used to express the behaviour of functions, function blocks and programs. It can also be used within the Sequential Function Charts to express the behaviour of steps, actions and transitions.
In this chapter we will review:
How to assign values to variables;
How to create simple and complex expressions;
The use of arithmetic, boolean and comparison operators;
Calling functions and function blocks;
Using language constructs for conditional statements and repeating a number of statements (iteration);
How to create nested language constructs.
Structured Text or ST is a high level language which has a syntax that on first appearance is very similar to PASCAL. Although there are some minor similarities to PASCAL, ST is a distinct language that has been specifically developed for industrial control applications.
The ST language has a comprehensive range of constructs for assigning values to variables, calling functions and function blocks, for creating expressions, for conditional evaluation of selected statements and for iteration, i.e. repeating selected sections of code.
The language statements can be written in a fairly free style where tabs, line feed characters and comments can be inserted anywhere between keywords and identifiers, i.e. wherever a space character is required. For the software developer, ST is fairly straightforward to...