'while'

while

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Repeat statements as long as a condition is fulfilled

Examples

    Integer i;
  algorithm
    i := 1;
    while i < 10 loop
      i := i + 1;
      ...
    end while;

Syntax

  while expression loop
    { algorithm ";" }
  end while

Description

The expression of a while clause shall be a scalar Boolean expression. The while-clause corresponds to while-statements in programming languages, and is formally defined as follows

  1. The expression of the while clause is evaluated.
  2. If the expression of the while-clause is false, the execution continues after the while-clause.
  3. If the expression of the while-clause is true, the entire body of the while clause is executed (except if a break statement or return statement is executed), and then execution proceeds at step 1.