https://wiki.beyondunreal.com/w/index.php?action=history&feed=atomWhile loop - Revision history2017-11-18T03:04:36ZRevision history for this page on the wikiMediaWiki 1.25.1https://wiki.beyondunreal.com/While_loop?diff=43914&oldid=prevWormbo: added quirks and recommendations2010-08-25T20:59:22Z<p>added quirks and recommendations</p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 20:59, 25 August 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="L12" >Line 12:</td>
<td colspan="2" class="diff-lineno">Line 12:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>   ''statement''''';'''</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>   ''statement''''';'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>This notation should be used with care because the statement could be the empty statement (a single semicolon), which would mean the loop only repeatedly evaluates its condition.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>This notation should be used with care because the statement could be the empty statement (a single semicolon), which would mean the loop only repeatedly evaluates its condition.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">==Quirks==</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">In [[Unreal Engine 1]] and [[Unreal Engine 2|2]] the compiler wasn't too strict when checking the [[until]] statement. You could not only omit it from a [[do loop]], but even add it to a '''while''' loop, essentially creating a doubly-checked loop that has a condition at the start that must be true and a condition at the end that must be false for the loop to continue.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Like with the other loop constructs, you can specify a single statement instead of the code block after the condition:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> '''while ('''''condition''''')'''</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">  ''statement''''';'''</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">It is recommended to enclose even a single statement in curly braces to prevent potential misunderstandings and oversights. The statement may even be empty, thus reducing the code to the '''while''' keyword and the loop condition. If you accidentally put a semicolon after a '''while''' statement with a block, the compiler will complain. This won't happen for the single statement version, so you wouldn't notice the problem until you execute the code and run into an infinite loop.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{navbox unrealscript}}</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{navbox unrealscript}}</div></td></tr>
</table>Wormbohttps://wiki.beyondunreal.com/While_loop?diff=33127&oldid=prevWormbo: New page: The '''while''' loop is a basic loop statement in UnrealScript, similar to the for loop and the do...until loop. ==Syntax== The '''while''' loop syntax is very similar to that...2008-10-12T06:28:56Z<p>New page: The '''while''' loop is a basic loop statement in <a href="/UnrealScript" title="UnrealScript">UnrealScript</a>, similar to the <a href="/For_loop" title="For loop">for loop</a> and the <a href="/Do...until_loop" class="mw-redirect" title="Do...until loop">do...until loop</a>. ==Syntax== The '''while''' loop syntax is very similar to that...</p>
<p><b>New page</b></p><div>The '''while''' loop is a basic loop statement in [[UnrealScript]], similar to the [[for loop]] and the [[do...until loop]].<br />
<br />
==Syntax==<br />
The '''while''' loop syntax is very similar to that of the [[if statement]]:<br />
'''while ('''''condition''''') {'''<br />
...<br />
'''}'''<br />
The condition must be a [[bool]] type expression. The code between the parentheses is executed repeatedly until either the condition becomes ''False'' or a [[break statement]] is encountered.<br />
<br />
Similar to the '''if''' statement, a '''while''' loop can be used to repeat a single statement instead of a block of code:<br />
'''while ('''''condition''''')'''<br />
''statement''''';'''<br />
This notation should be used with care because the statement could be the empty statement (a single semicolon), which would mean the loop only repeatedly evaluates its condition.<br />
<br />
{{navbox unrealscript}}</div>Wormbo