Exits (terminates) a loop. Valid inside any kind of loop.
Break [, LoopLabel]
[AHK_L 59+]: If specified, LoopLabel identifies which loop this statement should apply to; either by label name or numeric nesting level. If omitted or 1, this statement applies to the innermost loop in which it is enclosed. LoopLabel must be a constant value - variables and expressions are not supported. If a label is specified, it must point directly at a loop command.
The use of Break and Continue are encouraged over goto since they usually make scripts more readable and maintainable.
Continue, Loop, While-loop, For-loop, Blocks, Labels
Loop
{
...
if var > 25
break
...
if var <= 5
continue
}
; Break the outer loop from within a nested loop.
outer:
Loop 3
{
x := A_Index
Loop 3
{
if (x*A_Index = 6)
break outer ; Equivalent to break 2 or goto break_outer.
MsgBox %x%,%A_Index%
}
}
break_outer: ; For goto.