switch: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(example)
(Merging content with and redirecting to switch do. Too bold? Seems to make sense.)
Line 1: Line 1:
{{Command|= Comments
#REDIRECT [[switch do]]
____________________________________________________________________________________________
 
| arma |= Game name
 
|1.00|= Game version
____________________________________________________________________________________________
 
| See [[switch do]] |= Description
____________________________________________________________________________________________
 
| '''switch''' exp |= Syntax
 
|p1= exp: [[Anything]] |= Parameter 1
 
| [[Switch Type]] |= Return value
____________________________________________________________________________________________
 
|x1= <code>switch (_a) [[switch do|do]] {[[case]] 1 : {block}; [[case]] 2 : {block}; [[default]] {block};}</code> |= Example 1
|x2= <code>_color <nowiki>=</nowiki><br>switch (side player) do <br>{ <br>&nbsp;&nbsp;case west: {"ColorGreen"}; <br>&nbsp;&nbsp;case east: {"ColorRed"}; <br>};</code>
|x3= <code>_fn_moveForward  <nowiki>=</nowiki> { /*...code...*/ };<br/>_fn_moveBackward <nowiki>=</nowiki> { /*...code...*/ };<br/>_fn_invalidKey  <nowiki>=</nowiki> { /*...code...*/ };<br/><br/>switch true do {<br/>&nbsp;&nbsp;[[case]] (_dikCode in actionKeys "MoveForward")  : _fn_moveForward;<br/>&nbsp;&nbsp;[[case]] (_dikCode in actionKeys "MoveBackward") : _fn_moveBackward;<br/>&nbsp;&nbsp;[[default]]                                        _fn_invalidKey;<br/>};<br/></code>
|x4= <code>[[switch]] _var [[do]] {
[[case]] "0";
[[default]] {[[hint]] [[str]] ["default", _var]};
[[case]] "3": {[[hint]] [[str]] ["3", _var]};
[[case]] "1";
[[case]] "4";
[[case]] "2": {[[hint]] [[str]] ["2", _var]};
};</code>
<br>
<code>_var = "0"; //-> ["3", "0"]
_var = "1"; //-> ["2", "1"]
_var = "2"; //-> ["2", "2"]
_var = "3"; //-> ["3", "3"]
_var = "4"; //-> ["2", "4"]
_var = "5"; //-> ["default", "5"]</code>
 
| [[Control Structures]]  |= See also
 
}}
 
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
 
<!-- Note Section END -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|SWITCH]]
[[Category:Scripting Commands ArmA|SWITCH]]
[[Category:ArmA: Control Structures|SWITCH]]
[[Category:Command Group: Program Flow|SWITCH]]
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Revision as of 20:39, 4 April 2014

Redirect to: