Skip to content

break

A syntactic looping construction used in for, while, and until loops.

Syntax

break

Performance

The break statement exits a loop immediately, independently of the current value of the loop index or controlling boolean expression.

Examples

Here is an example of the break statement. It uses the file break.csd.

Example of the break opcode.
<CsoundSynthesizer>
<CsOptions>
-n
</CsOptions>
<CsInstruments>
0dbfs = 1

instr 1
    while (p4>0) do
        print p4
        if (p4 == 2) then
            break
        endif
        p4 = p4 - 1
    od
endin

</CsInstruments>
<CsScore>
i1 0 0 4
</CsScore>
</CsoundSynthesizer>

Its output should include lines like this, stopping at 2.000:

instr 1:    p4 = 4.000
instr 1:    p4 = 3.000
instr 1:    p4 = 2.000

See also

Program Flow Control: Looping Constructions

Credits

New in Csound version 7