> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/workflow/exit-loop.md).

# Exit loop

Exit loop 是用于立即强制退出当前循环(For 或 While)的操作,无论该循环是否已运行完规定的次数。退出后,系统将继续执行该循环块下方紧邻的操作。

此操作通常放置在 If 条件语句块内,用于处理异常情况或在提前找到所需结果时使用。

#### 实际示例:找到有效账户后停止检查

假设您使用 For 循环遍历 Excel 文件中的 100 个账户列表,以找出状态为 `"Live"` 的账户来使用。如果第 5 行已经是 "Live" 账户,您就不需要浪费时间继续运行剩下的 95 行。

* 配置方法:
  * 在 For 块内,使用 If 命令进行检查:`如果状态 = "Live"`。
  * 在该 If 块中,处理完获取账户后调用 Exit loop 操作。
* 结果:系统运行到第 5 行,发现条件成立,立即跳出 For 循环,继续执行下方的操作进行处理。

<figure><img src="https://1806980278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiDNNiVZHPKSIcyshmOTB%2Fuploads%2Fgit-blob-f0b4ffccf25fd2c69b3f3795249b2751c82648ef%2Fwf-01.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/workflow/exit-loop.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
