Formulas 7. Control structures

if ... then ... else ... fi

You can use conditional expressions in all formulas. For example,

3 * if 52% * 3809 > 2000 then 5 else 6 fi

evaluates to 15. Instead of fi, you can also use endif.

Another example: you can clip the absolute amplitude of a Sound to 0.5 by supplying the following formula:

if abs(self)>0.5 then if self>0 then 0.5 else -0.5 fi else self fi

The semicolon

The semicolon ends the evaluation of the formula. This can be convenient if you do not want to overwrite a long formula in your text field: the formula


evaluates to 800.

Links to this page

© ppgb, May 19, 2003