REPEAT Statement

The REPEAT statement is an iteration structure for a group of Structured Text (ST) statements. The "continue" condition is evaluated AFTER any iteration
REPEAT Statement
Name
REPEAT ... UNTIL ... END_REPEAT
Syntax
REPEAT <statement> ; <statement> ; ... UNTIL <Boolean_condition> END_REPEAT ;
IMPORTANT: Because the virtual machine is a synchronous system, input variables are not refreshed during REPEAT iterations. The change of state of an input variable cannot be used to describe the ending condition of a REPEAT statement.
Example
(* ST program using REPEAT statement *) (* this program uses specific "C" functions to read characters *) (* on a serial port *) str := ''; (* empty string *) nbchar := 0; IF ComIsReady ( ) THEN REPEAT str := str + ComGetChar ( ); nbchar := nbchar + 1; UNTIL ( (nbchar >= 16) OR NOT (ComIsReady ( )) ) END_REPEAT; END_IF;
To insert a REPEAT statement
  • From the
    Toolbox
    , drag the
    REPEAT
    element into the language container.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal