141
Structured Text (ST Language) Specifications Appendix B
Operator Priority
• Consider the operator priority in the structured text syntax, or enclose operations requiring priority in
parentheses.
Example: AND takes priority over OR. Therefore, in the example X OR Y AND Z, priority will be given to Y
AND Z.
CX-Programmer’s ST Input Screen Display
Text Display Color
The CX-Programmer automatically displays text in the following colors when it is input or pasted in the ST Input
Screen.
• Text keywords (reserved words): Blue
• Comments: Green
• Errors: Red
• Other: Black
Changing Fonts
To change font sizes or display colors, select Tools - Options - Display, and then click the ST Font Button.
The font name, font size (default is 8 point), and color can be changed.
Statements
Statement Function Example
End of statement Ends the statement ;
Comment All text between (* and *) is treated as a
comment.
(*comment*)
Assignment Substitutes the results of the expres-
sion, variable, or value on the right for
the variable on the left.
A:=B;
IF, THEN, ELSIF, ELSE, END_IF Evaluates an expression when the con-
dition for it is true.
IF (condition_1) THEN
(expression 1);
ELSIF (condition_2) THEN
(expression 2);
ELSE
(expression 3);
END_IF;
CASE, ELSE, END_CASE Evaluates an express based on the
value of a variable.
CASE (variable) OF
1: (expression 1);
2: (expression 2);
3: (expression 3);
ELSE
(expression 4);
END_CASE;
FOR, TO, BY, DO, END_FOR Repeatedly evaluates an expression
according to the initial value, final
value, and increment.
FOR (identifier) := (initial_value) TO
(final_value) BY (increment) DO
(expression);
END_FOR;
WHILE, DO, END_WHILE Repeatedly evaluates an expression as
long as a condition is true.
WHILE (condition) DO
(expression);
END_WHILE;
REPEAT, UNTIL, END_REPEAT Repeatedly evaluates an expression
until a condition is true.
REPEAT
(expression);
UNTIL (condition)
END_REPEAT;