title: Exit batch script from inside a function
body: <p>I have a problem with my batch file.
  It builds several programs automatically by doing something like this:</p>
  
  <ul>
  <li>set some compilation flags</li>
  <li>run 'gmake all'</li>
  <li>call the "check error level" function and if errorlevel 1, exit</li>
  </ul>
  
  <p>So it looks like this:</p>
  
  <pre><code>set FLAG=1
  ...
  gmake all
  call :interactive_check
  set OTHERFLAG=1
  ...
  gmake all
  call :interactive_check
  </code></pre>
  
  <p>There's 6 or 7 of these (and it might grow). So I made a function to check errorlevel instead of copy/pasting it at every step.
  The problem is this: the error checking is made through a function:</p>
  
  <pre><code>:interactive_check
  if errorlevel 1 (
  echo.
  echo /!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\
  echo Error in compilation process... exiting
  echo /!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\
  echo.
  cd %root_dir%
  exit /B 1
  ) ELSE (
  echo.Continuing to next step
  )
  goto:eof
  </code></pre>
  
  <p>Now, when running it, the <code>exit /B 1</code> simply exits the function, <strong>but not the batch file</strong>.</p>
  
  <p>Do you know how to exit the complete batch file without having to copy/paste my "if errorlevel 1.." at every step?</p>