|
|
(48 intermediate revisions by 19 users not shown) |
Line 1: |
Line 1: |
| {{Command|= Comments
| | #REDIRECT [[switch]] |
| ____________________________________________________________________________________________
| |
| | |
| | arma |= Game name
| |
| | |
| |1.00|= Game version
| |
| ____________________________________________________________________________________________
| |
| | |
| | Switch form. |= Description
| |
| ____________________________________________________________________________________________
| |
| | |
| | switch '''do''' block |= Syntax
| |
| | |
| |p1= switch: [[Switch Type]] |= Parameter 1
| |
| | |
| |p2= block: [[Code]] |= Parameter 2
| |
| | |
| | [[Anything]] |= Return value
| |
| ____________________________________________________________________________________________
| |
| |x1 = <code>[[switch]] (_a) '''do''' {[[case]] 1: {hint "1"}; [[case]] 2: {hint "2"}; default {hint "default"};} </code>
| |
| | |
| |x2 = <code>[[switch]] (_a) '''do''' {[[case]] true: {hint "true"}; [[case]] false: {hint "false"}; default {hint "default"};} </code>
| |
| | |
| |x3 = <code>[[switch]] (_a) '''do''' {[[case]] "string1": {hint "string1"}; [[case]] "string2": {hint "string2"}; default {hint "default"};} </code>
| |
| | |
| | |
| | [[Control Structures]] |= See also
| |
| | |
| }}
| |
| | |
| <h3 style="display:none">Notes</h3>
| |
| <dl class="command_description">
| |
| <!-- Note Section BEGIN -->
| |
| | |
| <dt class="note">'''[[User:ColonelSandersLite|ColonelSandersLite]]'''</dt><dd class="note"><br>
| |
| Be careful of the parenthesis around the variable you're switching on. If you accidentally use braces instead (ex: switch {_myVar} do{...), it won't error, but will always return default.<br>
| |
| </dd>
| |
| | |
| <dd class="notedate">Posted on 11 Aug, 2008</dd>
| |
| <dt class="note">'''[[User:Dr_Eyeball|Dr_Eyeball]]'''</dt><dd class="note">
| |
| Using [[switch]] with strings is case-sensitive, (unlike string comparisons).
| |
| </dd>
| |
| | |
| <dt class="note">'''[[User:General_Barron|General Barron]]'''</dt><dd class="note">
| |
| To be safe about the case sensitivity issue, use the [[toLower]] or [[toUpper]] command to force all strings to a certain case.
| |
| </dd>
| |
| | |
| | |
| <!-- Note Section END -->
| |
| </dl>
| |
| | |
| [[Category:Scripting Commands|DODSWITCH]]
| |
| [[Category:Scripting Commands ArmA|DODSWITCH]]
| |
| [[Category:ArmA: Control Structures|DOSWITCH]]
| |
| [[Category:Command Group: Program Flow|DOSWITCH]]
| |