ABB ST语言编程(9)
时间:2025-07-06
时间:2025-07-06
System 800xA Training
IFs may be nested to many levels. A better structure to be used instead of nesting isthe CASE structure.This is very useful when many conditions need evaluation; thereare several forms:CASE…OF
Operator
CASE Integer Expression OF
Integer Literal1 : Statement(s);
END_CASE;value of an integer variable or an integerexpression.
The <integer literal> is one or several integer
values or one or several ranges of values.
the appropriate statements) executed. One
variation is to permit a range of values to be
tested rather than an exact single value.
If none of the test literals match the result of
the expression then the statement(s) in the
ELSE clause will be executed. If no ELSE
exists, none of the statements will be
executed.CASE Integer Expression OFInteger Literal1 : Statement(s);Integer Literal2 : Statement(s);Integer Literal3: Statement(s);ELSEStatement(s);END_CASE;
13.3.6Iteration Structures
Several iteration constructs exist: They should be used with extreme caution. Duringthe iteration of the loop, the CPU remains in the loop. If a loop has a large number ofiterations then the normal scan time may be easily exceeded.
NOTE!Only use these constructs when you know exactly howmany iterations are going to be done.iption
statements) to be executed repeatedly for a given
number of times. The counter used in the repetition
process can be used in the statements.
In the example, the statements between the FOR
and END_FOR will be executed 16 times.
WHILELevel > 80.0 DO
Statement(s);
END_WHILE;WHILE statement is used in order to allow astatement (or statements) to be executed repeatedlywhile a certain condition is True.
This separates it from theFOR statement. It has
some similarities with theREPEAT statement.
REPEAT statement is used in order to allow a
statement (or statements) to be executed repeatedly
until a certain condition is True.
Note that the test to exit the loop is placed at the end,
so a minimum of one execution of the statement(s)
will occur even if the expression is true at the time
the loop is entered.
EXIT statement whenever you want to
terminate a loop immediately and continue execution
from the first line after the iteration statement.OperatorFORi := 0 to 15 DOStatement(s);END_FOR;REPEATStatement(s);UNTILBoolean ExpressionEND_REPEAT;EXIT
Chapter13-9
…… 此处隐藏:318字,全部文档内容请下载后查看。喜欢就下载吧 ……上一篇:小学二年级平移练习题