https://wiki.beyondunreal.com/w/index.php?action=history&feed=atomFor loop - Revision history2017-11-18T02:16:29ZRevision history for this page on the wikiMediaWiki 1.25.1https://wiki.beyondunreal.com/For_loop?diff=33117&oldid=prevWormbo: New page: The '''for''' loop is one of four different loop statements in UnrealScript. The others are the Do/Until, While and ForEach loops. ==Syntax== The general syntax of the '''...2008-10-11T07:21:29Z<p>New page: The '''for''' loop is one of four different loop statements in <a href="/UnrealScript" title="UnrealScript">UnrealScript</a>. The others are the <a href="/Do/Until" class="mw-redirect" title="Do/Until">Do/Until</a>, <a href="/While" class="mw-redirect" title="While">While</a> and <a href="/ForEach" class="mw-redirect" title="ForEach">ForEach</a> loops. ==Syntax== The general syntax of the '''...</p>
<p><b>New page</b></p><div>The '''for''' loop is one of four different loop statements in [[UnrealScript]]. The others are the [[Do/Until]], [[While]] and [[ForEach]] loops.<br />
<br />
==Syntax==<br />
The general syntax of the '''for''' loop is as follows:<br />
'''for ('''''initstatement''''';''' ''loopcondition''''';''' ''updatestatement''''')'''<br />
''statement''''';'''<br />
Instead of a single statement, it is more common to follow up with a block of code, even if it only contains a single statement as well:<br />
'''for ('''''initstatement''''';''' ''loopcondition''''';''' ''updatestatement''''') {'''<br />
...<br />
'''}'''<br />
The ''initstatement'' must be exactly one assignment or function call and is executed right before the loop is entered for the first time.<br />
The ''loopcondition'' must be a [[bool]] type expression and is evaluated before each (including the first) loop iteration. If the condition evaluates to ''False'', the loop ends and code execution continues at the first statement after the '''for''' loop.<br />
The ''updatestatement'' must be exactly one assignment or function call and is executed at the end of each loop iteration right before the loop condition is reevaluated.<br />
All three parts in the parentheses must be specified. Unlike other languages that allow you to omit these expressions, the UnrealScript compiler will complain if any of them is missing. Also unlike other languages the UnrealScript compiler will complain about comma-separated assignments as initialization or update statements.<br />
<br />
'''Note:''' The compiler also allows the empty statement (a lonely semicolon) as ''statement'' after the '''for''' statement. This is basically the same as specifying an empty block of code. Any other statements following the semicolon are ''not'' part of the loop! Be wary of this when using the single-statement form of the '''for''' loop.<br />
<br />
{{navbox unrealscript}}</div>Wormbo