repeat...until

InstallShield 2022 » InstallScript Language Reference

The repeat statement is analogous to the do...while loop in the C language. It also is very similar to the InstallScript while statement.

There are two main differences between repeat and while in InstallScript:

The repeat statement must loop at least once. A while statement might not loop at all.
A while statement terminates when the expression evaluates as false. A repeat statement terminates when the expression evaluates as true.

To create a repeat loop:

1. Set the variable you will be using in the conditional test as you would for a while loop.
2. Type repeat on its own line with no punctuation.
3. Build the operation(s) that you want repeated.
4. Add the operation that changes the test variable (for example, nCount = nCount + 1, or nCount = SomeVariable).
5. End the loop with an until statement containing the conditional test in parentheses.

The following example demonstrates repeat loop syntax:

    nCount = 1;

    repeat

        MessageBox("Count is less than 5", INFORMATION);

        nCount = nCount + 1;

    until (nCount = 5);

Note:You cannot define a label within the repeat statement.

See Also