Statement Descriptions
REPEAT Statement
158
Example 2: While X<3000, the value of X is doubled, and the value is substi-
tuted for the array variable DATA[1]. The value of X is then multiplied by 2
again, and the value is substituted for the array variable DATA[2]. This process
is repeated.
n:=1'
WHILE X<3000 DO
X:=X*2;
DATA[n]:=X;
n:=n+1;
END_WHIE;
■ Summary
This statement is used to repeatedly execute an expression until a specified
condition is true.
■ Reserved Words
REPEAT, UNTIL, END_REPEAT
■ Statement Syntax
REPEAT
<expression>;
UNTIL <condition>
END_REPEAT
■ Processing Flow Chart
Expression
False
Condition
True
End
■ Usage
Use the REPEAT statement to repeat processing for as long as a condition is
met after specified processing, when the number of iterations is undetermined
beforehand (depends on whether the condition is met). This statement can be
used to determine whether to repeat processing according to the results of
specified processing execution (post-test loop).
■
Description
The expression will execute the first time without a condition. Thereafter, the
condition equation will be evaluated. If the condition is false, the expression
will be executed again. If the condition is true, processing will end without exe-
cuting the expression.
■ Precautions
• REPEAT must be used together with END_REPEAT.
• Even if the condition equation is true before the expression has been exe-
cuted, the expression will be executed.
Iteration
Section 5-5
Need help?
Do you have a question about the CX-PROGRAMMER V8.1 and is the answer not in the manual?