switch: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
Lou Montana (talk | contribs) m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame( +[0-9])?|Game [Vv]ersion( +[0-9])?|Game Version \(number surrounded by NO SPACES\)|Arguments in MP|MP[Aa]rg|Multiplayer Arguments( \("local" or "global"\))?|Effects|Execution|Effects...) |
||
Line 1: | Line 1: | ||
{{Command | {{Command | ||
| arma1 | | arma1 | ||
|gr1= Program Flow | |gr1= Program Flow | ||
|1.00 | |1.00 | ||
| Creates a switch type that can be used inside a [[switch do|switch-do]] block. | | Creates a switch type that can be used inside a [[switch do|switch-do]] block. | ||
<br><br> | <br><br> | ||
{{Important | When it comes to strings, switch case matching is <b>case-sensitive</b>}} | {{Important | When it comes to strings, switch case matching is <b>case-sensitive</b>}} | ||
| [[switch]] condition | | [[switch]] condition | ||
|p1= condition: [[Anything]] | |p1= condition: [[Anything]] | ||
| [[Switch Type]] | | [[Switch Type]] | ||
|x1= <code>[[private]] _mySwitch = [[switch]] "Test"; | |x1= <code>[[private]] _mySwitch = [[switch]] "Test"; | ||
_mySwitch [[do]] { {{codecomment|/* Something */}} };</code> | _mySwitch [[do]] { {{codecomment|/* Something */}} };</code> | ||
|x2= <code>[[switch]] (_condition) [[do]] { | |x2= <code>[[switch]] (_condition) [[do]] { | ||
Line 26: | Line 26: | ||
[[case]] 2: { [[hint]] "2" }; | [[case]] 2: { [[hint]] "2" }; | ||
[[default]] { [[hint]] "default" }; | [[default]] { [[hint]] "default" }; | ||
};</code> | };</code> | ||
|x3= | |x3= | ||
Line 35: | Line 35: | ||
[[case]] "string4": { [[hint]] "string3 or string4" }; | [[case]] "string4": { [[hint]] "string3 or string4" }; | ||
[[default]] { [[hint]] "default" }; | [[default]] { [[hint]] "default" }; | ||
};</code> | };</code> | ||
| [[Control Structures]] [[switch do]] [[a:b]] [[case]] [[default]] | | [[Control Structures]] [[switch do]] [[a:b]] [[case]] [[default]] | ||
}} | }} | ||
Revision as of 11:27, 18 January 2021
Description
- Description:
- Creates a switch type that can be used inside a switch-do block.
- Groups:
- Program Flow
Syntax
- Syntax:
- switch condition
- Parameters:
- condition: Anything
- Return Value:
- Switch Type
Examples
- Example 1:
private _mySwitch = switch "Test"; _mySwitch do { /* Something */ };
- Example 2:
switch (_condition) do { case 1: { hint "1" }; case 2: { hint "2" }; default { hint "default" }; };
- Example 3:
switch (_condition) do { case "string1"; case "string2": { hint "string1 or string2" }; case "string3"; case "string4": { hint "string3 or string4" }; default { hint "default" }; };
Additional Information
- See also:
- Control Structures switch do a:b case default
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