The IEC 61131-3 ST assignment statement assigns the value of an expression to a variable. The assignment statement uses this syntax:
variable-reference := expression;
Where
If a string value is too long to fit a Variable Reference, a runtime error is reported.
If you need to truncate a string to fit a Variable Reference, use the LEFT() Function to limit the string length. For example:
StringVariable := LEFT( LongString, 254 );
Note: Before Fernhill SCADA Version 3.81, no runtime error was reported if a string was truncated during variable assignment.
A := 12.5;
C[0] := -12;
Position.Angle := ATAN2( Y, X ); Position.Distance = SQRT( X * X + Y * Y );
PreviousPosition := Position
The above examples use these Variable Declarations:
TYPE PolarCoordinates : STRUCT Angle : LREAL; Distance : LREAL; End_STRUCT End_TYPE VAR A : LREAL; X, Y : LREAL; C : ARRAY [0..5] OF INT; NewPosition, PreviousPosition : PolarCoordinates; End_VAR
IEC 61131-3 Second Edition: Table 56.1.
IEC 61131-3 Third Edition: Table 72.1.
For other Structured Text (ST) statement types.
To learn about variable references that can be used on the left of the := assignment operator.
To learn about expressions that can be used on the right of the := assignment operator.
For the meaning of terms used in Fernhill SCADA.