https://wiki.beyondunreal.com/w/index.php?action=history&feed=atomFlow control - Revision history2017-11-18T03:02:33ZRevision history for this page on the wikiMediaWiki 1.25.1https://wiki.beyondunreal.com/Flow_control?diff=43244&oldid=prevEliot: 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&oldid=43243">Show changes</a>Eliothttps://wiki.beyondunreal.com/Flow_control?diff=43243&oldid=prevEliot: Added navbox2010-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'> </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>After you write code following a "case" label, you must use a "break" statement to cause execution to go past the end of the "switch" statement. If you don't use a "break", execution "falls through" to the next "case" handler.</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>After you write code following a "case" label, you must use a "break" statement to cause execution to go past the end of the "switch" statement. If you don't use a "break", execution "falls through" to the next "case" handler.</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;">{{navbox unrealscript}}</ins></div></td></tr>
</table>Eliothttps://wiki.beyondunreal.com/Flow_control?diff=32984&oldid=prevIkuto at 17:17, 6 September 20082008-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"> </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'> </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:  </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>UnrealScript supports all the standard flow-control statements of C/C++/Java:  </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>
</table>Ikutohttps://wiki.beyondunreal.com/Flow_control?diff=32981&oldid=prevIkuto: 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 == "For" loops let you cycle through a loop as long as some condition is met. For example: <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 />
"For" loops let you cycle through a loop as long as some condition is met. For example:<br />
<br />
<uscript>// Example of "for" loop.<br />
function ForExample()<br />
{<br />
local int i;<br />
log( "Demonstrating the for loop" );<br />
for( i=0; i<4; i++ )<br />
{<br />
log( "The value of i is " $ i );<br />
}<br />
log( "Completed with i=" $ i);<br />
}</uscript><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 "for" loop expressions just update a counter, you can also use "for" 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 />
<uscript>for( i=0; i<4; i++ )<br />
log( "The value of i is " $ i );</uscript><br />
<br />
Or you can execute multiple statements, surrounded by brackets, like this: <br />
<br />
<uscript>for( i=0; i<4; i++ )<br />
{<br />
log( "The value of i is" );<br />
log( i );<br />
}</uscript><br />
<br />
== Do-While Loops ==<br />
<br />
"Do"-"Until" 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 />
<uscript>// Example of "do" loop.<br />
function DoExample()<br />
{<br />
local int i;<br />
log( "Demonstrating the do loop" );<br />
do<br />
{<br />
log( "The value of i is " $ i );<br />
i = i + 1;<br />
} until( i == 4 );<br />
log( "Completed with i=" $ i);<br />
}</uscript><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 />
"While" loops let you cycle through a loop while some starting expression is true.<br />
<br />
<uscript>// Example of "while" loop.<br />
function WhileExample()<br />
{<br />
local int i;<br />
log( "Demonstrating the while loop" );<br />
while( i < 4 )<br />
{<br />
log( "The value of i is " $ i );<br />
i = i + 1;<br />
}<br />
log( "Completed with i=" $ i);<br />
}</uscript><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 "break" command exits out of the nearest loop ("For", "Do", or "While").<br />
<br />
<uscript>// Example of "while" loop.<br />
function WhileExample()<br />
{<br />
local int i;<br />
log( "Demonstrating break" );<br />
for( i=0; i<10; i++ )<br />
{<br />
if( i == 3 )<br />
break;<br />
log( "The value of i is " $ i );<br />
}<br />
log( "Completed with i=" $ i );<br />
}</uscript><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 "Goto" command goes to a label somewhere in the current function or state.<br />
<br />
<uscript>// Example of "goto".<br />
function GotoExample()<br />
{<br />
log( "Starting GotoExample" );<br />
goto Hither;<br />
Yon:<br />
log( "At Yon" );<br />
goto Elsewhere;<br />
Hither:<br />
log( "At Hither" );<br />
goto Yon;<br />
Elsewhere:<br />
log( "At Elsewhere" );<br />
}</uscript><br />
<br />
The output is:<br />
<br />
Starting GotoExample<br />
At Hither<br />
At Yon<br />
At Elsewhere<br />
<br />
== Conditional Statements ==<br />
<br />
"If", "Else If", and "Else" let you execute code if certain conditions are met.<br />
<br />
<uscript>// Example of simple "if".<br />
if( LightBrightness < 20 )<br />
log( "My light is dim" );<br />
<br />
// Example of "if-else".<br />
if( LightBrightness < 20 )<br />
log( "My light is dim" );<br />
else<br />
log( "My light is bright" );<br />
<br />
// Example if "if-else if-else".<br />
if( LightBrightness < 20 )<br />
log( 'My light is dim" );<br />
else if( LightBrightness < 40 )<br />
log( "My light is medium" );<br />
else if( LightBrightness < 60 )<br />
log( "My light is kinda bright" );<br />
else<br />
log( "My light is very bright" );<br />
<br />
// Example if "if" with brackets.<br />
<br />
if( LightType == LT_Steady )<br />
{<br />
log( "Light is steady" );<br />
}<br />
else<br />
{<br />
log( "Light is not steady" );<br />
}</uscript><br />
<br />
== Case Statements ==<br />
<br />
"Switch", "Case", "Default", and "Break" let you handle lists of conditions easily.<br />
<br />
<uscript>// 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( "There is no lighting" );<br />
break;<br />
case LT_Steady:<br />
log( "There is steady lighting" );<br />
break;<br />
case LT_Backdrop:<br />
log( "There is backdrop lighting" );<br />
break;<br />
<br />
default:<br />
log( "There is dynamic" );<br />
break;<br />
}<br />
}</uscript><br />
<br />
A "switch" statement consists of one or more "case" statements, and an optional "default" statement. After a switch statement, execution goes to the matching "case" statement if there is one; otherwise execution goes to the "default" statement; otherwise execution continues past the end of the "select" statement.<br />
<br />
After you write code following a "case" label, you must use a "break" statement to cause execution to go past the end of the "switch" statement. If you don't use a "break", execution "falls through" to the next "case" handler.</div>Ikuto