WHILE

WHILE C

EXECUTES THE NEXT STATEMENT OR THE NEXT BLOCK OF STATEMENTS UNTIL END_WHILE WHILE THE CONDITION C IS TRUE

  • Type: Command
  • Parameter: 1
  • Group: Structures

ACTION

The command WHILE defines the beginning of a loop WHILE/END_WHILE. It uses the result of the logical condition (True or False) to execute or not the statement or the block of statements until the keyword END_WHILE.

The "condition" is a single logical expression (built with comparators >, <, >=, <>, =, ...) or a complex expression combined with logical operators AND, OR, NOT and parenthesis. Only the result (True or False) is used to execute or not the statement or the block of statements.

The command is the beginning of a loop and must be used with the keyword END_WHILE :

WHILE Condition

Statement(s)

END_WHILE

While the condition is true, the statement or the block of statements till END_WHILE is(are) executed. Otherwise, the execution jumps to the statement just after END_WHILE.

SYNTAX: WHILE C

  • in:
  • WHILE C
  • Statement(s)
  • END_WHILE
  • C: logical expression.

USE

  • WHILE is used,associated to END_WHILE, to repeat a statement or a block of statements depending on a logical condition.

ERROR

  • If C is not a correct logical expression.
  • If there is no END_WHILE after WHILE.

EXAMPLE

dim a

a=0

rem display all the digits from 0 to 9

while a<10

print a

a=a+1

end_while

SEE ALSO

END_WHILE

IF

THEN

ELSE

END_IF

REPEAT

UNTIL

AND

OR

NOT