switch: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "|= Game name" to "|Game name=") |
Lou Montana (talk | contribs) m (Tiny fixes in examples and description) |
||
Line 7: | Line 7: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| Creates a switch type that can be used inside a [[switch do]] | | Creates a switch type that can be used inside a [[switch do|switch-do]] block. |DESCRIPTION= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| [[switch]] | | [[switch]] condition |SYNTAX= | ||
|p1= | |p1= condition: [[Anything]] |PARAMETER1= | ||
| [[Switch Type]] |RETURNVALUE= | | [[Switch Type]] |RETURNVALUE= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1= <code>_mySwitch = [[switch]] "Test"; | |x1= <code>[[private]] _mySwitch = [[switch]] "Test"; | ||
_mySwitch [[do]] {/*Something*/};</code> |EXAMPLE1= | _mySwitch [[do]] { {{codecomment|/* Something */}} };</code> |EXAMPLE1= | ||
|x2= | |x2= <code>[[switch]] (_condition) [[do]] { | ||
<code>[[switch]] (_condition) [[do]] { | |||
[[case]] 1: { [[hint]] "1" }; | [[case]] 1: { [[hint]] "1" }; | ||
[[case]] 2: { [[hint]] "2" }; | [[case]] 2: { [[hint]] "2" }; | ||
[[default]] { [[hint]] "default" }; | [[default]] { [[hint]] "default" }; | ||
};</code> | };</code> |Example2= | ||
|x3= | |||
<code>[[switch]] (_condition) [[do]] { | <code>[[switch]] (_condition) [[do]] { | ||
[[case]] "string1"; | [[case]] "string1"; | ||
Line 34: | Line 33: | ||
[[case]] "string4": { [[hint]] "string3 or string4" }; | [[case]] "string4": { [[hint]] "string3 or string4" }; | ||
[[default]] { [[hint]] "default" }; | [[default]] { [[hint]] "default" }; | ||
};</code> | | };</code> |EXAMPLE3= | ||
| [[Control Structures]] [[switch do]] [[a:b]] [[case]] [[default]] |SEEALSO= | | [[Control Structures]] [[switch do]] [[a:b]] [[case]] [[default]] |SEEALSO= | ||
}} | }} | ||
Line 48: | Line 46: | ||
</dl> | </dl> | ||
[[Category:Scripting Commands| | |||
[[Category:Scripting Commands ArmA| | [[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]] | |||
[[Category:ArmA: Control Structures|{{uc:{{PAGENAME}}}}]] | [[Category:ArmA: Control Structures|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Command Group: Program Flow|{{uc:{{PAGENAME}}}}]] | [[Category:Command Group: Program Flow|{{uc:{{PAGENAME}}}}]] | ||
Revision as of 15:40, 11 September 2019
Description
- Description:
- Creates a switch type that can be used inside a switch-do block.
- Groups:
- Uncategorised
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