148
Structured Text (ST Language) Specifications
Appendix B
Description
Condition 1
= If true, execute
expression 1
Condition 1
= If false,
Condition 2
= If true, execute
expression 2
Condition 2
= If false,
Condition 3
= If true, execute
expression 3
etc.
Condition n
= If true, execute
expression n
If none of these conditions are met,
condition m
is executed.
Precautions
• IF must be used together with END_IF.
•
Condition_
@
contains the true or false result of the equation (e.g., IF(A>10)).
A boolean (BOOL data type) variable only can also be specified as the
condition
rather than an equation.
For boolean conditions, the result is true when the variable value is 1 (ON) and false when it is 0 (OFF).
• Statements that can be used in
expression_
@
are assignment statements, IF, CASE, FOR, WHILE, or
REPEAT.
• Multiple statements can be executed in
expression_
@
. Be sure to use a semicolon (;) delimiter between
multiple statements in an
expression
.
• The ELSE statement can be omitted. When ELSE is omitted, no operation is executed if the result of any
condition
equation is false.
Examples
Example 1: If variable A>0 is true, variable X will be substituted with numerical value 10.
If A>0 is false, but variable B=1, variable X will be substituted with numerical value 1.
If A>0 is false, but variable B=2, variable X will be substituted with numerical value 2.
If either of these conditions is met, variable X will be substituted with numerical value 0.
IF A>0 THEN X:=10;
ELSIF B=1 THEN X:=1;
ELSIF B=2 THEN X:=2;
ELSE X:=0;
END_IF;
CASE Statement
Summary
This statement executes an expression containing a selected integer that matches the value from an integer
equation. If the selected integer value is not the same, either no expression or a specified expression is exe-
cuted.
Reserved Word
CASE
Statement Syntax
CASE
<
integer_equation
>
OF
<
integer_equation
_
value_1
>
:
<
expression_1
>
;
<
integer_equation
_
value_2
>
:
<
expression_2
>
;
...
<
integer_equation
_
value_n
>
:
<
expression_n
>
;
ELSE
<
expression_m
>
;
END_CASE;
Содержание 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...