switch: Difference between revisions
Jump to navigation
Jump to search
m (Text replace - "{{uc:{{PAGENAME}}}}" to "{{uc:{{PAGENAME}}}} {{uc:{{PAGENAME}}}}") |
m (added white space) |
||
Line 17: | Line 17: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1= <code>switch (_a) [[switch do|do]] {[[case]] 1: {block}; [[case]] 2 : {block}; [[default]] {block};}</code> |= Example 1 | |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> case west: {"ColorGreen"}; <br> case east: {"ColorRed"}; <br>};</code> | |x2= <code>_color <nowiki>=</nowiki><br>switch (side player) do <br>{ <br> case west: {"ColorGreen"}; <br> 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/> [[case]] (_dikCode in actionKeys "MoveForward") : _fn_moveForward;<br/> [[case]] (_dikCode in actionKeys "MoveBackward") : _fn_moveBackward;<br/> [[default]] _fn_invalidKey;<br/>};<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/> [[case]] (_dikCode in actionKeys "MoveForward") : _fn_moveForward;<br/> [[case]] (_dikCode in actionKeys "MoveBackward") : _fn_moveBackward;<br/> [[default]] _fn_invalidKey;<br/>};<br/></code> |
Revision as of 07:34, 4 February 2012
Description
- Description:
- See switch do
- Groups:
- Uncategorised
Syntax
- Syntax:
- switch exp
- Parameters:
- exp: Anything
- Return Value:
- Switch Type
Examples
- Example 1:
switch (_a) do {case 1 : {block}; case 2 : {block}; default {block};}
- Example 2:
_color =
switch (side player) do
{
case west: {"ColorGreen"};
case east: {"ColorRed"};
};- Example 3:
_fn_moveForward = { /*...code...*/ };
_fn_moveBackward = { /*...code...*/ };
_fn_invalidKey = { /*...code...*/ };
switch true do {
case (_dikCode in actionKeys "MoveForward") : _fn_moveForward;
case (_dikCode in actionKeys "MoveBackward") : _fn_moveBackward;
default _fn_invalidKey;
};
Additional Information
- See also:
- Control Structures
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note