WHILE Statement
The WHILE statement is an iteration structure for a group of Structured Text (ST) statements. The "continue" condition is evaluated BEFORE any iteration
WHILE Statement | |||
Name | WHILE ... DO ... END_WHILE | ||
Syntax | WHILE <Boolean_expression> DO <statement> ; <statement> ; ... END_WHILE ; |
IMPORTANT:
Since the virtual machine is a synchronous
system, input variables are not refreshed during WHILE iterations. The change of state of an
input variable cannot be used to describe the condition of a WHILE statement.
Example
(* ST program using WHILE statement *) (* this program uses specific "C" functions to read characters *) (* on a serial port *) str := ''; (* empty string *) nbchar := 0; WHILE ((nbchar < 16) & ComIsReady ( )) DO str := str + ComGetChar ( ); nbchar := nbchar + 1; END_WHILE;
To insert a WHILE statement
- From theToolbox, drag theWHILEelement into the language container.
Provide Feedback