Evaluates an expression while the condition is non-zero.

WHILE(expr, statements)

WHILE (expr) { statements; }

expr |
- |
Any valid expression that evaluates to a scalar. |

statements |
- |
Any valid statements separated by semicolons to evaluate while expr is non-zero. |

Result of statements.

differentiates the current Window until the maximum value is greater than 10.0

multiplies variable a by 2 until the resulting value is greater than 25.

{

a *= 2;

}

same as above, except in SPL form.

f := 1.0

W1: gsin(100,.01,f);label(sprintf("Frequency: %g", f))

W2: spectrum(W1, 1024)

f:=1;**while**(f <= 100, f++)

W1: gsin(100,.01,f);label(sprintf("Frequency: %g", f))

W2: spectrum(W1, 1024)

f:=1;

W2 displays a remarkably simple demonstration of aliasing errors due to undersampling the sinewave in W1.

See LOOP for a faster but less flexible iteration construct.

For best performance, try to avoid loops altogether by exploiting the vectorized nature of SPL. For example:

y = {};

t = 0..0.01..1

n = 1;

**while** (n <= 101)

{

y[n] = sin(2*pi*10*t[n]);

}

t = 0..0.01..1

n = 1;

{

y[n] = sin(2*pi*10*t[n]);

}

can be performed much faster, more intuitively and concisely with:

t = 0..0.01..1;

y = sin(2*pi*10*t);

y = sin(2*pi*10*t);

or even faster with:

y = gsin(101, .01, 10);