<?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_8";
//]]></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>continue</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 continue function"/>
<meta name="rh-index-keywords" content="continue"/>
<meta name="search-keywords" content="continue"/>
</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="continue">
<span>continue</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>continue</h1>
<p>The <tt>continue</tt> statement has the following basic syntax:</p>
<p class="code">continue;</p>
<p>If used inside of a statement that forms a loop (<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>), it will immediately end the current
<a class="tooltip" title="An iteration is a single pass through a set of operations in your project code. One form of iteration in computer programming is via loops. A loop will repeat a certain segment of code until a condition is met and it can proceed further. Each time the computer runs a loop, it is known as an iteration. In simple terms, iteration is the process of repeating a particular snippet of code over and over again to perform a certain action.">iteration</a> and jump back to the beginning of the loop starting a new iteration and ommitting any code that comes after the <span class="inline">continue</span> within the loop. It can also
be used within the <a href="with.htm"><tt>with</tt></a> statement, where it will cause the code to skip to the next instance and run again. Note that if <tt>continue</tt> is used outside of any of these contexts it will give an error.</p>
<p>Below is an example of use in a <tt>for</tt> loop:</p>
<p class="code">var _val = 0;<br/> for (var i = 0; i < 10; i += 1)<br/> {
<br/> if (val_array[i] <= 0)<br/> {<br/> continue;<br/> }<br/> _val += val_array[i];<br/> }
<br/> draw_text(32, 32, "Positive Values Total = " + string(_val));</p>
<p>Below is an example of use in a <span class="inline">while</span> loop:</p>
<p class="code">var file = file_text_open_read("Game_Data.txt");<br/> var _num = 0;<br/> while (!file_text_eof(file))<br/> {<br/> var _s = file_text_readln(file);<br/> if (_s == "")<br/> {<br/> continue;<br/> }<br/> str[num++] = _s;<br/> }<br/> file_text_close(file);
</p>
<p>Below is an example of use in a <span class="inline">do / until</span> loop:</p>
<p class="code">do<br/> {
<br/> var _x = random(room_width);<br/> var _y = random(room_height);<br/> if (instance_position(_x, y, obj_Enemy)<br/> {
<br/> continue;
<br/> }
<br/> instance_create_layer(_x, _y, "Instances", obj_Enemy);<br/> }
<br/> until (instance_count(obj_Enemy) >= 10);</p>
<p>Below you can find an example of use in a <span class="inline">repeat</span> loop:</p>
<p class="code">repeat(10)<br/> { <br/> var _x = random(room_width);<br/> var _y = random(room_height);<br/> if (instance_position(_x, y, obj_Enemy)<br/> {
<br/> continue;
<br/> }
<br/> instance_create_layer(_x, _y, "Instances", obj_Enemy);<br/> }</p>
<p>Finally, an example of use in a <span class="inline">with</span> statement:</p>
<p class="code">with (obj_Enemy_Parent)<br/> {<br/> if (object_index == obj_Enemy_InDestructible)<br/> {<br/> continue;<br/> }<br/> hp -= 100;<br/> if (hp <= 0)<br/> {<br/> instance_destroy();<br/> }<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="exit.htm">exit</a></div>
</div>
</div>
<h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
</div>
<!-- KEYWORDS
continue
-->
<!-- TAGS
continue
-->
</body></html>