Repeat Until

Navigation:  Language Reference > Statements >

Repeat Until

Previous pageReturn to chapter overviewNext page

Syntax

code

 repeat

         equation;

         equation;

         ....

 until condition;

Description

The repeat statement is designed to execute equation(s) repeatedly, as long as the condition is true. The condition is evaluated after the equations are executed.

 

It is the user's responsibility to guarantee that the execution of the repeat statement finishes by making the condition become false at a certain time.

Examples

variables

 real i,z[4];

initialequations

 z = 0;

code // Use code to ensure sequential execution

 i = 1;

 repeat

         // executed 4 times:

         z[i] = cos(time) * i;

         // i is incremented to guarantee a stop of the loop

         i = i + 1;

 until (i > rows(z));

Limitations

1.The output of the condition must be a boolean. If the boolean does not become false, the loop never ends! There are no limitations to the number of equations that can be used within the repeat statement.
2.If needed, always use the equal operator (==) in the condition.
3.Equations within an repeat statement have to be written in the correct order of execution, i.e. they are not rewritten into a causal form but executed sequentially.