Until [AHK_L 59+]
Applies a condition to the continuation of a Loop or For-loop.
Loop { ... } Until Expression
Parameters
- Expression
Any valid expression.
Remarks
The expression is evaluated once after each iteration, and is evaluated even if continue was used. If the expression evaluates to false (which is an empty string or the number 0), the loop continues; otherwise, the loop is broken and execution continues at the line following Until.
Loop Until is shorthand for the following:
Loop { ... if (Expression) break }
However, Loop Until is often easier to understand and unlike the above, can be used with a single-line action. For example:
Loop x *= 2 Until x > y
Until can be used with any Loop or For. For example:
Loop, Read, %A_ScriptFullPath% lines .= A_LoopReadLine . "`n" Until A_Index=5 ; Read the first five lines. MsgBox % lines
If A_Index is used in Expression, it contains the index of the iteration which has just finished.
Related
Loop, While-loop, For-loop, Break, Continue, Blocks, Files-and-folders loop, Registry loop, File-reading loop, Parsing loop, If (expression)