/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

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Until | AutoHotkey</title>
  5. <meta name="description" content="The Until statement applies a condition to the continuation of a Loop or For-loop." />
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  9. <script src="../static/content.js" type="text/javascript"></script>
  10. <script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
  11. </head>
  12. <body>
  13. <h1>Until <span class="ver">[AHK_L 59+]</span></h1>
  14. <p>根据条件判断是否继续执行 Loop For 循环.</p>
  15. <pre class="Syntax">
  16. <span class="func">Loop</span> {
  17. ...
  18. } <span class="func">Until</span> <i>Expression</i>
  19. </pre>
  20. <h2 id="Parameters">参数</h2>
  21. <dl>
  22. <dt>Expression</dt>
  23. <dd><p>任何有效的<a href="../Variables.htm#Expressions">表达式</a>.</p></dd>
  24. </dl>
  25. <h2 id="Remarks">备注</h2>
  26. <p>在每次重复执行后都会计算一次表达式, 即使使用了 <a href="Continue.htm">continue</a> 也会进行计算. 如果表达式计算结果为 false(即为空字符串或数值 0), 循环继续; 否则循环被打破且跳到 <i>Until</i> 之后一行执行.</p>
  27. <p>Loop Until 是下列结构的简写形式:</p>
  28. <pre>Loop {
  29. ...
  30. if (<i>Expression</i>)
  31. break
  32. }</pre>
  33. <p>不过, Loop Until 通常更容易理解, 且与上面不同的是, 它还可以使用单行动作. 例如:</p>
  34. <pre>Loop
  35. x *= 2
  36. Until x &gt; y</pre>
  37. <p><i>Until</i> 可以使用在任何 Loop For 循环中. 例如:</p>
  38. <pre>Loop, Read, %A_ScriptFullPath%
  39. lines .= A_LoopReadLine . "`n"
  40. Until A_Index=5 <em>; 读取前五行.</em>
  41. MsgBox % lines
  42. </pre>
  43. <p>如果 <a href="../Variables.htm#Index">A_Index</a> 用在 <i>Expression</i> , 那么它的值为刚结束的那次循环的索引.</p>
  44. <h2 id="Related">相关</h2>
  45. <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>
  46. </body>
  47. </html>