switch: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Ooops. Putting back the categories.)
(Created own page for switch as it is an operator for it's own (see https://foxhound.international/arma-3-sqf-grammar.html for reference))
Line 1: Line 1:
#REDIRECT [[switch do]]
{{Command|= Comments
____________________________________________________________________________________________
 
| arma |= Game name
 
|1.00|= Game version
____________________________________________________________________________________________
 
| Creates a switch type that can be used inside a [[switch do]] -block |= Description
____________________________________________________________________________________________
 
| [[switch]] arg|= Syntax
 
|p1= arg: [[Anything]] |= Parameter 1
 
| [[Switch Type]] |= Return value
____________________________________________________________________________________________
 
|x1= <code>_mySwitch = [[switch]] "Test";
_mySwitch [[do]] {/*Something*/};</code> |= Example 1
 
|x2= <code>[[switch]] (_a) [[do]] { [[case]] 1 : { /*...code...*/ }; [[case]] 2 : { /*...code...*/ }; [[default]] { /*...code...*/ }; };</code>
<br>
<code>[[switch]] (_condition) [[do]] {
    [[case]] 1: { [[hint]] "1" };
    [[case]] 2: { [[hint]] "2" };
    [[default]] { [[hint]] "default" };
};</code>
<br>
<code>[[switch]] (_condition) [[do]] {
    [[case]] "string1";
    [[case]] "string2": { [[hint]] "string1 or string2" };
    [[case]] "string3";
    [[case]] "string4": { [[hint]] "string3 or string4" };
    [[default]] { [[hint]] "default" };
};</code> |= Example 2
 
| [[Control Structures]], [[switch do]],  [[a:b]], [[case]], [[default]] |= See also
 
}}
 
<h3 style="display:none">Notes</h3>
<dl class="command_description">
 
<!-- Note Section BEGIN -->
 
<!-- Note Section END -->
</dl>


[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
Line 5: Line 52:
[[Category:ArmA: Control Structures|{{uc:{{PAGENAME}}}}]]
[[Category:ArmA: Control Structures|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Program Flow|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Program Flow|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
<!-- DISCONTINUE Notes -->

Revision as of 10:44, 3 January 2017

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Creates a switch type that can be used inside a switch do -block
Groups:
Uncategorised

Syntax

Syntax:
switch arg
Parameters:
arg: Anything
Return Value:
Switch Type

Examples

Example 1:
_mySwitch = switch "Test"; _mySwitch do {/*Something*/};
Example 2:
switch (_a) do { case 1 : { /*...code...*/ }; case 2 : { /*...code...*/ }; default { /*...code...*/ }; };
switch (_condition) do { case 1: { hint "1" }; case 2: { hint "2" }; default { hint "default" }; };
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 Structuresswitch do, a:bcasedefault

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

Notes