<p>You can use the Loop Interrupt block. Just make sure the name used in the Loop Interrupt block matches the name of the loop inside of the My Block.</p>

<p><a href="https://i.sstatic.net/17Gn6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/17Gn6.png" alt="Loop Interrupt block"></a></p>

CC BY-SA 3.0
2017-08-16T16:46:59.230Z
Make sure to make explicit calls to turn off the motors
banno
CC BY-SA 3.0
2017-08-09T19:24:39.087Z
2017-08-09T19:24:39.087Z
David Lechner
<p>I have a "general-purpose" line-follower encapsulated in a MyBlock that runs an infinite loop. </p>

<p>Now, in a client program, I would like to interrupt that MyBlock if some condition is met; what the condition is should be determined by the client, so I don't want to put that logic into the MyBlock. </p>

<p>I also don't want to terminate the program altogether, and I want to keep the loop in the MyBlock. </p>

<p>Is there a way to break out of the MyBlock?</p>

<programming><ev3-g>
How do you interrupt a MyBlock?
ae5880
# How do you interrupt a MyBlock?

(Asked by: username_0 on 2017-08-09)

I have a "general-purpose" line-follower encapsulated in a MyBlock that runs an infinite loop.

Now, in a client program, I would like to interrupt that MyBlock if some condition is met; what the condition is should be determined by the client, so I don't want to put that logic into the MyBlock.

I also don't want to terminate the program altogether, and I want to keep the loop in the MyBlock.

Is there a way to break out of the MyBlock?

**Tags:** programming, ev3-g


---

## 1 answers

### Answer by username_1 on 2017-08-09. Score: 3

You can use the Loop Interrupt block. Just make sure the name used in the Loop Interrupt block matches the name of the loop inside of the My Block.

[![Loop Interrupt block](https://i.sstatic.net/17Gn6.png)](https://i.sstatic.net/17Gn6.png)

> **Comments:**
> **username_2**: Make sure to make explicit calls to turn off the motors  

---

