switch: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (edited "see also" part to remove unneeded commas)
m (template:command argument fix)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Creates a switch type that can be used inside a [[switch do]] -block |= Description
| Creates a switch type that can be used inside a [[switch do]] -block |DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[switch]] arg|= Syntax
| [[switch]] arg|SYNTAX=


|p1= arg: [[Anything]] |= Parameter 1
|p1= arg: [[Anything]] |PARAMETER1=


| [[Switch Type]] |= Return value
| [[Switch Type]] |RETURNVALUE=
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>_mySwitch = [[switch]] "Test";
|x1= <code>_mySwitch = [[switch]] "Test";
_mySwitch [[do]] {/*Something*/};</code> |= Example 1
_mySwitch [[do]] {/*Something*/};</code> |EXAMPLE1=


|x2= <code>[[switch]] (_a) [[do]] { [[case]] 1 : { /*...code...*/ }; [[case]] 2 : { /*...code...*/ }; [[default]] { /*...code...*/ }; };</code>
|x2= <code>[[switch]] (_a) [[do]] { [[case]] 1 : { /*...code...*/ }; [[case]] 2 : { /*...code...*/ }; [[default]] { /*...code...*/ }; };</code>
Line 34: Line 34:
     [[case]] "string4": { [[hint]] "string3 or string4" };
     [[case]] "string4": { [[hint]] "string3 or string4" };
     [[default]] { [[hint]] "default" };
     [[default]] { [[hint]] "default" };
};</code> |= Example 2
};</code> |EXAMPLE2=


| [[Control Structures]] [[switch do]] [[a:b]] [[case]] [[default]] |= See also
| [[Control Structures]] [[switch do]] [[a:b]] [[case]] [[default]] |SEEALSO=


}}
}}

Revision as of 14:49, 7 April 2019

-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 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

Notes