Structured Text (ST)
- A ST program is a list of statements.
- Each statement describes an action and must end with a semi-colon (;).
- The presentation of the text has no meaning for a ST program.
- You can insert blank characters and line breaks where you want in the program text.
Comments
Comment text can be entered anywhere in an ST program.
- Comment text:
- Has no meaning for the execution of the program.
- Must begin with (* and end with *).
- Can be entered on several lines (i.e., a comment text can include line breaks).
- Cannot be nested.
Expressions
Each statement describes an action and can include evaluation of complex expressions.
An expression is evaluated:
- From the left to the right.
- According to the default priority order of operators.
- The default priority can be changed using parentheses Parenthesis ( ).
Arguments of an expression can be:
- Declared Variables.
- Constant Expressions.
- Function Call.
Statements
Basic Statements
These are the available basic statements that can be entered in an ST program:
- Assignment := (assignment)
- Call a Function Block
Conditional Statements
These are the available conditional statements in ST Language:
Loop Statements
These are the available statements for describing loops in ST Language:
- FOR TO BY END_FOR
- Loops with FOR instructions are slow.
Optimize your code by replacing such iterations with a WHILE statement.
- Loops with FOR instructions are slow.
- REPEAT UNTIL END_REPEAT
- WHILE DO END_WHILE
Iteration of statement execution.
The BY statement is optional (default value is 1)
FOR iCount := 0 TO 100 BY 2 DO
MyVar := MyVar + 1;
END_FOR;
Repeat a list of statements.
Condition is evaluated on loop exit after the statements.
iCount := 0;
REPEAT
MyVar := MyVar + 1;
iCount := iCount + 1;
UNTIL iCount < 100 END_REPEAT;
Repeat a list of statements.
Condition is evaluated on loop entry before the statements.
iCount := 0;
WHILE iCount < 100 DO
iCount := iCount +1;
MyVar := MyVar + 1;
END_WHILE;
Other Statements
These are some other statements in ST Language:
- WAIT / WAIT_TIME - Suspend the execution.
- ON - Conditional execution of statements: provides a simpler syntax for checking the rising edge of a Boolean condition.
-
-
ST provides an automatic completion of typed words.
See Auto-completion of Wordsfor more information.
See Also