> 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="/files/yh9aXNAjNeWV3b7v8XoW" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
