gm-docs-parser 1.0.0

A collection of typings for GameMaker Studio 2 manual pages
Documentation
<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
    }
    if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
      origWidth = innerWidth;
      origHeight = innerHeight;
      onresize = reDo;
    }
    onerror = null;
  //]]>
  </script>
  <style type="text/css">/*<![CDATA[*/

    < !-- div.WebHelpPopupMenu {
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 4;
      visibility: hidden;
    }

    p.WebHelpNavBar {
      text-align: right;
    }

    -->
  
/*]]>*/</style>

  <script type="text/javascript">//<![CDATA[

    gRootRelPath = "../../..";
    gCommonRootRelPath = "../../..";
    gTopicId = "9.1.2.0_7";
  
//]]></script>

  <script type="text/javascript" src="../../../template/scripts/rh.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/common.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/topic.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../whxdata/projectsettings.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../template/styles/topic.min.css"/>
  <link rel="stylesheet" type="text/css" href="../../../template/Charcoal_Grey/topicheader.css"/>
  <meta name="topic-status" content="Draft"/>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>break</title>
  <meta name="generator" content="Adobe RoboHelp 2019"/>
  <link rel="stylesheet" href="../../../assets/css/default.css" type="text/css"/>
  <meta name="rh-authors" content="Mark Alexander"/>
  <meta name="topic-comment" content="Page outlining the break function"/>
  <meta name="rh-index-keywords" content="break"/>
  <meta name="search-keywords" content="break"/>
</head>

<body>
  <div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
    <div class="logo">
    </div>
    <div class="nav">
      <div class="title" title="break">
        <span>break</span>
      </div>
      <div class="gotohome" title="Click here to see this page in full context">
        <span>Click here to see this page in full context</span>
      </div>
    </div>
  </div>
  <div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>



  <!--<div class="body-scroll" style="top: 150px;">-->
  <h1>break</h1>
  <p>The <span class="inline"><tt>break</tt></span> statement is used to end prematurely a <a href="for.htm"><tt>for</tt></a>, <a href="repeat.htm"><tt>repeat</tt></a>, <a href="while.htm"><tt>while</tt></a> or <a href="do___until.htm"><tt>do / until</tt></a>    loop of some kind, or to tell a <a href="switch.htm"><tt>switch</tt></a> statement to end at that point, or to prematurely end a <a href="with.htm"><tt>with</tt></a> call. Please see the individual pages for these different functions to get a more
    in-depth explanation of how it can be used under each circumstance. Note that if <tt>break</tt> is used outside of any of these contexts it will give an error.</p>
  <p>Below you can see a few basic examples of how <span class="inline">break</span> can be used, and its syntax is simply:</p>
  <p class="code">break;</p>
  <p><tt>break</tt> in a <tt>for</tt> loop:</p>
  <p class="code">for (var i = 0; i &lt; 10; i += 1)<br/>     {
    <br/>     if (array[i] == 234)<br/>         {
    <br/>         break;
    <br/>         }
    <br/>     }
    <br/> num = i;</p>
  <p><tt>break</tt> in a <tt>repeat</tt> loop:</p>
  <p class="code">var i = 0;<br/> var temp = 0;<br/> repeat (10)<br/>     {
    <br/>     temp += array[i];<br/>     if (temp &gt; max_total)<br/>         {
    <br/>         break;
    <br/>         }
    <br/>     else
    <br/>         {
    <br/>         i += 1;<br/>         }
    <br/>     }
  </p>
  <p><tt>break</tt> in a <tt>while</tt> loop:</p>
  <p class="code">var i = 0;<br/> while (!place_free(x, y))<br/>     {
    <br/>     x = random(room_width);<br/>     y = random(room_height);<br/>     if (i &gt; 50)<br/>         {
    <br/>         break;
    <br/>         }
    <br/>     else
    <br/>         {
    <br/>         i+=1;
    <br/>         }
    <br/>     }
  </p>
  <p><span class="inline">break</span> in a <span class="inline">do / until</span> loop:</p>
  <p class="code">var _id = noone;<br/> do
    <br/>     {<br/>     _id = list[| 0];<br/>     if instance_exists(_id)<br/>         {<br/>         _break;<br/>         }<br/>     ds_list_delete(list, 0);<br/>     }<br/> until (ds_list_empty(list));<br/> target = _id;</p>
  <p><tt>break</tt> when using <tt>with</tt>:</p>
  <p class="code">var count = 0;<br/> with (obj_Enemy)<br/>     {
    <br/>     count++;
    <br/>     if (count &gt; 10)<br/>         {
    <br/>         break;
    <br/>         }
    <br/>     hp = 100;<br/>     }
  </p>
  <p><span class="inline">break</span> in a <span class="inline">switch</span>:</p>
  <p class="code">switch (keyboard_key)<br/>     {
    <br/>     case vk_left:<br/>     case ord(&quot;A&quot;):<br/>         x -= 4;<br/>         break;
    <br/>     case vk_right:<br/>     case ord(&quot;D&quot;):<br/>         x += 4;<br/>         break;
    <br/>     case vk_up:<br/>     case ord(&quot;W&quot;):<br/>         y -= 4;<br/>         break;
    <br/>     case vk_down:<br/>     case ord(&quot;S&quot;):<br/>         y += 4;<br/>         break;
    <br/>     }
  </p>
  <p> </p>
  <p> </p>
  <p> </p>
  <div class="footer">
    <div class="buttons">
      <div class="clear">
        <div style="float:left">Back: <a href="../Language_Features.htm">Language Features</a></div>
        <div style="float:right">Next: <a href="continue.htm">continue</a></div>
      </div>
    </div>
    <h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
  </div>
  <!-- KEYWORDS
break
-->
  <!-- TAGS
break
-->

</body></html>