Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T16:46:59.230Z
Answers.Text: Make sure to make explicit calls to turn off the motors
Answers.UserDisplayName: banno
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-09T19:24:39.087Z
Answers.LastActivityDate: 2017-08-09T19:24:39.087Z
Answers.UserDisplayName: David Lechner
Body: <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>
  
Tags: <programming><ev3-g>
Title: How do you interrupt a MyBlock?
UserDisplayName: ae5880
ThreadText: # 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  
  
  ---
  
  