/zh-cn/docs/commands/Until.htm
https://github.com/wyagd001/wyagd001.github.io · HTML · 55 lines · 47 code · 8 blank · 0 comment · 0 complexity · 9afcad1ede9bf881b77ff539fce3eb94 MD5 · raw file
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Until | AutoHotkey</title>
- <meta name="description" content="The Until statement applies a condition to the continuation of a Loop or For-loop." />
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <link href="../static/theme.css" rel="stylesheet" type="text/css" />
- <script src="../static/content.js" type="text/javascript"></script>
- <script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
- </head>
- <body>
- <h1>Until <span class="ver">[AHK_L 59+]</span></h1>
- <p>根据条件判断是否继续执行 Loop 或 For 循环.</p>
- <pre class="Syntax">
- <span class="func">Loop</span> {
- ...
- } <span class="func">Until</span> <i>Expression</i>
- </pre>
- <h2 id="Parameters">参数</h2>
- <dl>
- <dt>Expression</dt>
- <dd><p>任何有效的<a href="../Variables.htm#Expressions">表达式</a>.</p></dd>
- </dl>
- <h2 id="Remarks">备注</h2>
- <p>在每次重复执行后都会计算一次表达式, 即使使用了 <a href="Continue.htm">continue</a> 也会进行计算. 如果表达式计算结果为 false(即为空字符串或数值 0), 循环继续; 否则循环被打破且跳到 <i>Until</i> 之后一行执行.</p>
- <p>Loop Until 是下列结构的简写形式:</p>
- <pre>Loop {
- ...
- if (<i>Expression</i>)
- break
- }</pre>
- <p>不过, Loop Until 通常更容易理解, 且与上面不同的是, 它还可以使用单行动作. 例如:</p>
- <pre>Loop
- x *= 2
- Until x > y</pre>
- <p><i>Until</i> 可以使用在任何 Loop 或 For 循环中. 例如:</p>
- <pre>Loop, Read, %A_ScriptFullPath%
- lines .= A_LoopReadLine . "`n"
- Until A_Index=5 <em>; 读取前五行.</em>
- MsgBox % lines
- </pre>
- <p>如果 <a href="../Variables.htm#Index">A_Index</a> 用在 <i>Expression</i> 中, 那么它的值为刚结束的那次循环的索引.</p>
- <h2 id="Related">相关</h2>
- <p><a href="Loop.htm">Loop</a>, <a href="While.htm">While 循环</a>, <a href="For.htm">For 循环</a>, <a href="Break.htm">Break</a>, <a href="Continue.htm">Continue</a>, <a href="Block.htm">区块</a>, <a href="LoopFile.htm">文件和文件夹循环</a>, <a href="LoopReg.htm">注册表循环</a>, <a href="LoopReadFile.htm">文件读取循环</a>, <a href="LoopParse.htm">解析循环</a>, <a href="IfExpression.htm">If (表达式)</a></p>
- </body>
- </html>