</head> <body> <h1>Break</h1> <p>Exits (terminates) any type of <a href="../Language.htm#loop-statement">loop statement</a>.</p> <pre class="Syntax"><span class="func">Break</span> <span class="optional">, LoopLabel</span></pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>LoopLabel <span class="ver">[AHK_L 59+]</span></dt> <dd><em>LoopLabel</em> identifies which loop this statement should apply to; either by <a href="../misc/Labels.htm">label name</a> or numeric nesting level. If omitted or 1, this statement applies to the innermost loop in which it is enclosed. <em>LoopLabel</em> must be a constant value - variables and expressions are not supported. If a <a href="../misc/Labels.htm">label</a> is specified, it must point directly at a <a href="../Language.htm#loop-statement">loop statement</a>.</dd> </dl> <h2 id="Remarks">Remarks</h2> <p>The use of Break and <a href="Continue.htm">Continue</a> are encouraged over <a href="Goto.htm">Goto</a> since they usually make scripts more readable and maintainable.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="Continue.htm">Continue</a>, <a href="Loop.htm">Loop</a>, <a href="While.htm">While-loop</a>, <a href="For.htm">For-loop</a>, <a href="Block.htm">Blocks</a>, <a href="../misc/Labels.htm">Labels</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Breaks the loop if <var>var</var> is greater than 25.</p> <pre>Loop { <em>; ...</em> if (var &gt; 25) break <em>; ...</em> if (var &lt;= 5) continue }</pre> </div> <div class="ex" id="ExBreakOuter"> <p><a class="ex_number" href="#ExBreakOuter"></a> Breaks the outer loop from within a nested loop.</p> <pre>outer: Loop 3 { x := A_Index Loop 3 { if (x*A_Index = 6) break outer <em>; Equivalent to <b>break 2</b> or <b>goto break_outer</b>.</em> MsgBox %x%,%A_Index% } } break_outer: <em>; For goto.</em> </pre> </div> </body> </html>