https://wiki.beyondunreal.com/w/index.php?action=history&feed=atom Continue statement - Revision history 2017-11-18T03:07:29Z Revision history for this page on the wiki MediaWiki 1.25.1 https://wiki.beyondunreal.com/Continue_statement?diff=33162&oldid=prev Wormbo: New page: The '''continue''' statement can be used in do, while, for and foreach loops to skip to the end of the current iteration step and reevaluate the loop condition to check if ... 2008-10-25T09:06:33Z <p>New page: The &#039;&#039;&#039;continue&#039;&#039;&#039; statement can be used in <a href="/Do" class="mw-redirect" title="Do">do</a>, <a href="/While" class="mw-redirect" title="While">while</a>, <a href="/For" class="mw-redirect" title="For">for</a> and <a href="/Foreach" class="mw-redirect" title="Foreach">foreach</a> loops to skip to the end of the current iteration step and reevaluate the loop condition to check if ...</p> <p><b>New page</b></p><div>The '''continue''' statement can be used in [[do]], [[while]], [[for]] and [[foreach]] loops to skip to the end of the current iteration step and reevaluate the loop condition to check if another iteration should be started. The '''for''' and '''foreach''' loops evaluate their update step first.<br /> <br /> '''Continue''' is usually used to skip the rest of an iteration step if certain preconditions for the code are no longer met. Note that it is always possible to wrap the code in an [[if]] block instead, but sometimes a simple '''if'''...'''continue''' statement combination is much more elegant and expresses the problem more logically.<br /> <br /> ==Syntax==<br /> Nothing special here:<br /> '''continue;'''<br /> Just the keyword &quot;continue&quot; followed by the standard semicolon to terminate the statement.<br /> <br /> ==Examples==<br /> Let's say, you want to perform a certain operation for all NavigationPoint actors, but PlayerStarts also receive some kind of additional treatment. Without the '''continue''' statement you'd probably write:<br /> &lt;uscript&gt;<br /> local NavigationPoint NP;<br /> <br /> /*<br /> UE1/2 code here!<br /> For UE3 you'd use:<br /> foreach WorldInfo.AllNavigationPoints(class'NavigationPoint', NP)<br /> */<br /> for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint) {<br /> // generic code for all navpoints here<br /> <br /> if (PlayerStart(NP) != None) {<br /> // specific code for PlayerStarts here<br /> }<br /> }<br /> &lt;/uscript&gt;<br /> Using the '''continue''' statement you could reduce the number of nested blocks a bit:<br /> &lt;uscript&gt;<br /> for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint) {<br /> // generic code for all navpoints here<br /> <br /> if (PlayerStart(NP) == None)<br /> continue;<br /> <br /> // specific code for PlayerStarts here<br /> }<br /> &lt;/uscript&gt;<br /> The resulting behavior is the same as in the previous example without '''continue'''. Note the reversed '''if''' condition!<br /> <br /> It really depends on the situation whether to use the '''continue''' statement in a simple '''if''' or an '''if''' block. Don't just use either of them, just because they work. Think about which one makes more sense when trying to understand what the code does.<br /> <br /> {{navbox unrealscript}}</div> Wormbo