145
Structured Text (ST Language) Specifications
Appendix B
Example 3: Substitute variable A with the constant 10.
A:=10;
Precautions
The data type of the equation, variable, or constant to be assigned must be the same as the data type of the
variable to be substituted. Otherwise, a syntax error will occur.
Control Statements
IF Statement (Single Condition)
Summary
This statement is used to execute an expression when a specified condition is met. If the condition is not met,
a different expression is executed.
Reserved Words
IF, THEN, (ELSE), END_IF
Note
ELSE can be omitted.
Statement Syntax
IF
<
condition
>
THEN
<
expression_1
>
;
ELSE
<
expression_2
>
;
END_IF;
Process Flow Diagram
Usage
Use the IF statement to perform a different operation depending on whether a single condition (condition equa-
tion) is met.
Description
Condition
= If true, execute
expression_1
Condition
= If false, execute
expression_2
Precautions
• IF must be used together with END_IF.
• The
condition
must include a true or false equation for the evaluation result.
Example: IF(A>10)
The
condition
can also be specified as a boolean variable only rather than an equation. As a result, the
variable value is 1 (ON) = True result, 0 (OFF) = False result.
• Statements that can be used in
expression_1
and
expression_2
are assignment statements, IF, CASE,
FOR, WHILE, or REPEAT.
Condition
False
True
Expression 1
Expression 2
Содержание CS1-H Series
Страница 3: ...iv...
Страница 5: ...vi...
Страница 7: ...viii TABLE OF CONTENTS...
Страница 15: ...xvi Application Precautions 4...
Страница 151: ...136 Procedures Section 3 2...
Страница 153: ...138 Data Types Appendix A...
Страница 177: ...162 External Variables Appendix C...
Страница 181: ...166 Revision History...