https://wiki.beyondunreal.com/w/index.php?action=history&feed=atom Flow control - Revision history 2017-11-18T03:02:33Z Revision history for this page on the wiki MediaWiki 1.25.1 https://wiki.beyondunreal.com/Flow_control?diff=43244&oldid=prev Eliot: I think this page should copy all contents of the statement pages to here just like the Types and Literals page. 2010-05-15T07:10:01Z <p>I think this page should copy all contents of the statement pages to here just like the Types and Literals page.</p> <a href="https://wiki.beyondunreal.com/Flow_control?diff=43244&amp;oldid=43243">Show changes</a> Eliot https://wiki.beyondunreal.com/Flow_control?diff=43243&oldid=prev Eliot: Added navbox 2010-05-15T06:44:04Z <p>Added navbox</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 06:44, 15 May 2010</td> </tr><tr><td colspan="2" class="diff-lineno" id="L212" >Line 212:</td> <td colspan="2" class="diff-lineno">Line 212:</td></tr> <tr><td class='diff-marker'>&#160;</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'>&#160;</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'>&#160;</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>After you write code following a &quot;case&quot; label, you must use a &quot;break&quot; statement to cause execution to go past the end of the &quot;switch&quot; statement. If you don't use a &quot;break&quot;, execution &quot;falls through&quot; to the next &quot;case&quot; handler.</div></td><td class='diff-marker'>&#160;</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>After you write code following a &quot;case&quot; label, you must use a &quot;break&quot; statement to cause execution to go past the end of the &quot;switch&quot; statement. If you don't use a &quot;break&quot;, execution &quot;falls through&quot; to the next &quot;case&quot; handler.</div></td></tr> <tr><td colspan="2">&#160;</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">&#160;</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;">{{navbox unrealscript}}</ins></div></td></tr> </table> Eliot https://wiki.beyondunreal.com/Flow_control?diff=32984&oldid=prev Ikuto at 17:17, 6 September 2008 2008-09-06T17:17:34Z <p></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 17:17, 6 September 2008</td> </tr><tr><td colspan="2" class="diff-lineno" id="L1" >Line 1:</td> <td colspan="2" class="diff-lineno">Line 1:</td></tr> <tr><td colspan="2">&#160;</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;">{{stub}}</ins></div></td></tr> <tr><td class='diff-marker'>&#160;</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>UnrealScript supports all the standard flow-control statements of C/C++/Java: &#160;</div></td><td class='diff-marker'>&#160;</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>UnrealScript supports all the standard flow-control statements of C/C++/Java: &#160;</div></td></tr> <tr><td class='diff-marker'>&#160;</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'>&#160;</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> </table> Ikuto https://wiki.beyondunreal.com/Flow_control?diff=32981&oldid=prev Ikuto: New page: UnrealScript supports all the standard flow-control statements of C/C++/Java: == For Loops == "For" loops let you cycle through a loop as long as some condition is met. For example: <u... 2008-09-06T17:01:13Z <p>New page: UnrealScript supports all the standard flow-control statements of C/C++/Java: == For Loops == &quot;For&quot; loops let you cycle through a loop as long as some condition is met. For example: &lt;u...</p> <p><b>New page</b></p><div>UnrealScript supports all the standard flow-control statements of C/C++/Java: <br /> <br /> == For Loops ==<br /> <br /> &quot;For&quot; loops let you cycle through a loop as long as some condition is met. For example:<br /> <br /> &lt;uscript&gt;// Example of &quot;for&quot; loop.<br /> function ForExample()<br /> {<br /> local int i;<br /> log( &quot;Demonstrating the for loop&quot; );<br /> for( i=0; i&lt;4; i++ )<br /> {<br /> log( &quot;The value of i is &quot; $ i );<br /> }<br /> log( &quot;Completed with i=&quot; $ i);<br /> }&lt;/uscript&gt;<br /> <br /> The output of this loop is:<br /> <br /> Demonstrating the for loop<br /> The value of i is 0<br /> The value of i is 1<br /> The value of i is 2<br /> The value of i is 3<br /> Completed with i=4<br /> <br /> In a for loop, you must specify three expressions separated by semicolons. The first expression is for initializing a variable to its starting value. The second expression gives a condition which is checked before each iteration of the loop executes; if this expression is true, the loop executes. If it's false, the loop terminates. The third condition gives an expression which increments the loop counter.<br /> <br /> Though most &quot;for&quot; loop expressions just update a counter, you can also use &quot;for&quot; loops for more advanced things like traversing linked lists, by using the appropriate initialization, termination, and increment expressions.<br /> <br /> In all of the flow control statements, you can either execute a single statement, without brackets, as follows:<br /> <br /> &lt;uscript&gt;for( i=0; i&lt;4; i++ )<br /> log( &quot;The value of i is &quot; $ i );&lt;/uscript&gt;<br /> <br /> Or you can execute multiple statements, surrounded by brackets, like this: <br /> <br /> &lt;uscript&gt;for( i=0; i&lt;4; i++ )<br /> {<br /> log( &quot;The value of i is&quot; );<br /> log( i );<br /> }&lt;/uscript&gt;<br /> <br /> == Do-While Loops ==<br /> <br /> &quot;Do&quot;-&quot;Until&quot; loops let you cycle through a loop while some ending expression is true.  Note that Unreal's do-until syntax differs from C/Java (which use do-while).<br /> <br /> &lt;uscript&gt;// Example of &quot;do&quot; loop.<br /> function DoExample()<br /> {<br /> local int i;<br /> log( &quot;Demonstrating the do loop&quot; );<br /> do<br /> {<br /> log( &quot;The value of i is &quot; $ i );<br /> i = i + 1;<br /> } until( i == 4 );<br /> log( &quot;Completed with i=&quot; $ i);<br /> }&lt;/uscript&gt;<br /> <br /> The output of this loop is:<br /> <br /> Demonstrating the do loop<br /> The value of i is 0<br /> The value of i is 1<br /> The value of i is 2<br /> The value of i is 3<br /> Completed with i=4<br /> <br /> == While Loops ==<br /> <br /> &quot;While&quot; loops let you cycle through a loop while some starting expression is true.<br /> <br /> &lt;uscript&gt;// Example of &quot;while&quot; loop.<br /> function WhileExample()<br /> {<br /> local int i;<br /> log( &quot;Demonstrating the while loop&quot; );<br /> while( i &lt; 4 )<br /> {<br /> log( &quot;The value of i is &quot; $ i );<br /> i = i + 1;<br /> }<br /> log( &quot;Completed with i=&quot; $ i);<br /> }&lt;/uscript&gt;<br /> <br /> The output of this loop is:<br /> <br /> Demonstrating the do loop<br /> The value of i is 0 The value of i is 1<br /> The value of i is 2<br /> The value of i is 3<br /> Completed with i=4<br /> <br /> == Break ==<br /> <br /> The &quot;break&quot; command exits out of the nearest loop (&quot;For&quot;, &quot;Do&quot;, or &quot;While&quot;).<br /> <br /> &lt;uscript&gt;// Example of &quot;while&quot; loop.<br /> function WhileExample()<br /> {<br /> local int i;<br /> log( &quot;Demonstrating break&quot; );<br /> for( i=0; i&lt;10; i++ )<br /> {<br /> if( i == 3 )<br /> break;<br /> log( &quot;The value of i is &quot; $ i );<br /> }<br /> log( &quot;Completed with i=&quot; $ i );<br /> }&lt;/uscript&gt;<br /> <br /> The output of this loop is:<br /> <br /> Demonstrating break<br /> The value of i is 0<br /> The value of i is 1<br /> The value of i is 2<br /> Completed with i=3<br /> <br /> == Goto ==<br /> <br /> The &quot;Goto&quot; command goes to a label somewhere in the current function or state.<br /> <br /> &lt;uscript&gt;// Example of &quot;goto&quot;.<br /> function GotoExample()<br /> {<br /> log( &quot;Starting GotoExample&quot; );<br /> goto Hither;<br /> Yon:<br /> log( &quot;At Yon&quot; );<br /> goto Elsewhere;<br /> Hither:<br /> log( &quot;At Hither&quot; );<br /> goto Yon;<br /> Elsewhere:<br /> log( &quot;At Elsewhere&quot; );<br /> }&lt;/uscript&gt;<br /> <br /> The output is:<br /> <br /> Starting GotoExample<br /> At Hither<br /> At Yon<br /> At Elsewhere<br /> <br /> == Conditional Statements ==<br /> <br /> &quot;If&quot;, &quot;Else If&quot;, and &quot;Else&quot; let you execute code if certain conditions are met.<br /> <br /> &lt;uscript&gt;// Example of simple &quot;if&quot;.<br /> if( LightBrightness &lt; 20 )<br /> log( &quot;My light is dim&quot; );<br />  <br /> // Example of &quot;if-else&quot;.<br /> if( LightBrightness &lt; 20 )<br /> log( &quot;My light is dim&quot; );<br /> else<br /> log( &quot;My light is bright&quot; );<br />  <br /> // Example if &quot;if-else if-else&quot;.<br /> if( LightBrightness &lt; 20 )<br /> log( 'My light is dim&quot; );<br /> else if( LightBrightness &lt; 40 )<br /> log( &quot;My light is medium&quot; );<br /> else if( LightBrightness &lt; 60 )<br /> log( &quot;My light is kinda bright&quot; );<br /> else<br /> log( &quot;My light is very bright&quot; );<br />  <br /> // Example if &quot;if&quot; with brackets.<br /> <br /> if( LightType == LT_Steady )<br /> {<br /> log( &quot;Light is steady&quot; );<br /> }<br /> else<br /> {<br /> log( &quot;Light is not steady&quot; );<br /> }&lt;/uscript&gt;<br /> <br /> == Case Statements ==<br /> <br /> &quot;Switch&quot;, &quot;Case&quot;, &quot;Default&quot;, and &quot;Break&quot; let you handle lists of conditions easily.<br /> <br /> &lt;uscript&gt;// Example of switch-case.<br /> function TestSwitch()<br /> {<br /> // Executed one of the case statements below, based on<br /> // the value in LightType.<br /> switch( LightType )<br /> {<br /> case LT_None:<br /> log( &quot;There is no lighting&quot; );<br /> break;<br /> case LT_Steady:<br /> log( &quot;There is steady lighting&quot; );<br /> break;<br /> case LT_Backdrop:<br /> log( &quot;There is backdrop lighting&quot; );<br /> break;<br /> <br /> default:<br /> log( &quot;There is dynamic&quot; );<br /> break;<br /> }<br /> }&lt;/uscript&gt;<br /> <br /> A &quot;switch&quot; statement consists of one or more &quot;case&quot; statements, and an optional &quot;default&quot; statement. After a switch statement, execution goes to the matching &quot;case&quot; statement if there is one; otherwise execution goes to the &quot;default&quot; statement; otherwise execution continues past the end of the &quot;select&quot; statement.<br /> <br /> After you write code following a &quot;case&quot; label, you must use a &quot;break&quot; statement to cause execution to go past the end of the &quot;switch&quot; statement. If you don't use a &quot;break&quot;, execution &quot;falls through&quot; to the next &quot;case&quot; handler.</div> Ikuto