Answers.Body: <p><strong>No, EV3 MyBlocks cannot be recursive.</strong> If a MyBlock contains a copy of itself, then the following error will be produced upon compiling:</p>
  
  <p><img src="https://i.sstatic.net/boTme.png" alt="The error produced when trying to put a MyBlock inside a MyBlock"></p>
  
  <p>For some reason, LEGO's programming software has become progressively less immediate about notifying you that this cannot be done. In EV3-G, it waits until compile to let you know that you can't do this. In NXT-G (the software for programming the NXT), trying to put a MyBlock in itself produces an error upon placing it. And in the Robotics Invention System 2.0 (the software for programming the RCX), it simply won't let go of the MyBlock you're dragging if you try and place it into itself.</p>
  
  <p>If you want a programming language for the EV3 that supports recursion, I'd like to offer <a href="http://www.lejos.org/ev3.php" rel="nofollow noreferrer" title="LeJOS EV3">LeJOS EV3</a> (Java-based, free) and <a href="http://www.robotc.net/" rel="nofollow noreferrer" title="ROBOTC">ROBOTC</a> (C-based, costs money) as alternatives. They're both EV3-compatible, and support recursion.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-12T22:30:46.570Z
Answers.LastActivityDate: 2014-07-12T22:30:46.570Z
Answers.UserDisplayName: HaydenStudios
Body: <p>Imagine I create a MyBlock called <code>function1</code> from a line of blocks. Can I call that block from within itself?</p>
  
  <p><img src="https://i.sstatic.net/KnPXe.png" alt="recursiceTestBlock"></p>
  
  <p>This is the program for the block <code>recursiveTest</code>.</p>
  
  <p>Will this block function properly?</p>
  
Tags: <mindstorms><ev3><programming><ev3-g>
Title: Can EV3-G MyBlocks be recursive?
UserDisplayName: JJOULK
ThreadText: # Can EV3-G MyBlocks be recursive?
  
  (Asked by: username_0 on 2014-04-10)
  
  Imagine I create a MyBlock called `function1` from a line of blocks. Can I call that block from within itself?
  
  ![recursiceTestBlock](https://i.sstatic.net/KnPXe.png)
  
  This is the program for the block `recursiveTest`.
  
  Will this block function properly?
  
  **Tags:** mindstorms, ev3, programming, ev3-g
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-12. Score: 2
  
  **No, EV3 MyBlocks cannot be recursive.** If a MyBlock contains a copy of itself, then the following error will be produced upon compiling:
  
  ![The error produced when trying to put a MyBlock inside a MyBlock](https://i.sstatic.net/boTme.png)
  
  For some reason, LEGO's programming software has become progressively less immediate about notifying you that this cannot be done. In EV3-G, it waits until compile to let you know that you can't do this. In NXT-G (the software for programming the NXT), trying to put a MyBlock in itself produces an error upon placing it. And in the Robotics Invention System 2.0 (the software for programming the RCX), it simply won't let go of the MyBlock you're dragging if you try and place it into itself.
  
  If you want a programming language for the EV3 that supports recursion, I'd like to offer [LeJOS EV3](http://www.lejos.org/ev3.php "LeJOS EV3") (Java-based, free) and [ROBOTC](http://www.robotc.net/ "ROBOTC") (C-based, costs money) as alternatives. They're both EV3-compatible, and support recursion.
  
  
  ---
  
  