REPEAT statement in ST
Syntax
REPEAT
...
UNTIL ...
END_REPEAT;
Meaning |
Use the REPEAT statement to specify that a group of statements (entered after REPEAT up to UNTIL) is to be executed repeatedly (at least once) until the Boolean →expression (entered after UNTIL) evaluates to value TRUE (or an equivalent). If the expression initially evaluates to value FALSE (or an equivalent), then group of statements is executed exactly one time. |
Example
FUNCTION_BLOCK ExampleRepeatDocumentation
VAR
count, sum, I : INT;
END_VAR
count :=
1
;
sum :=
0
;
REPEAT
sum := ADD(sum, count);
count := ADD(count,
1
);
UNTIL GT(count,
10
)
END_REPEAT; (* The variable
'sum'
equals
'45'
. *)
END_FUNCTION_BLOCK
No identification of infinite loops
Infinite loops are not identified and prevented by logi.CAD 3. Therefore, enter code in your application to prevent infinite loops (e.g. abort conditions by using IF-statements).