Repeat Statement - GE PACSystems RX7i Cpu Programmer's Reference Manual

Hide thumbs Also See for PACSystems RX7i:
Table of Contents

Advertisement

Chapter 8. Structured Text (ST) Programming
8.2.8

REPEAT Statement

The REPEAT loop repeatedly executes (iterates) a statement list contained within the
REPEAT...END_REPEAT construct until an exit condition is satisfied. It executes the statement list
first, then checks for the exit condition. This looping construct is useful when the statement list
needs to be executed at least once.
Format
REPEAT
StatementList;
UNTIL BooleanExpression END_REPEAT;
Where:
BooleanExpression
StatementList
Operation
The StatementList is executed. If the BooleanExpression is FALSE (0), then the loop is repeated;
otherwise, if the BooleanExpression is TRUE (1), the loop is exited. The statement list executes at
least once, since the BooleanExpression is evaluated at the end of the loop.
Note: It is possible to create an infinite loop that will cause the watchdog timer to expire. Avoid
infinite loops.
Example
The following code fragment reads values from an array until a value greater than 5 is found (or the
upper bound of the array is reached). Since at least one array value must be read, the REPEAT loop is
used. All variables in this example are of type DINT, UINT, or INT.
Index :=1;
REPEAT
Value:= @Index;
Index:=Index+1;
UNTIL Value > 5 OR Index >= UpperBound END_REPEAT;
380
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
Any expression that resolves to a Boolean value.
Any set of Structured Text statements.
GFK-2950C

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pacsystems rx3iPacsystems rsti-ep

Table of Contents