Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.00

Description

Description:

Executes SQF code, depending on variable evaluation.

String comparison is case-sensitive.

Syntax

Syntax:switch (var) do {evaluations}
Parameters:
  • var: Switch Type - Variable to evaluate.
  • evaluations: Code - One or more conditional code blocks, in the format: case Anything: {Code};
    Last (optional) block can be default {Code};("default" does not have a colon after it).
Return Value:Anything

Examples

Examples:
switch (count allUnits) do {
  case 1: {hint "1"}; 
  case 2: {hint "2"}; 
  default {hint "more than 2"};
};

switch (alive tank1) do {
  case true: {hint "alive"}; 
  case false: {hint "dead"}; 
};

switch (getMarkerColor "mrk1") do {
  case "ColorBlue": {hint "blue"}; 
  case "ColorRed": {hint "red"}; 
  default {hint "something else"};
};

_force=switch (side player) do {
  case west: {"BLUFOR"}; 
  case east: {"OPFOR"}; 
  default {""};
};

Additional Information

See also: switch-Statement
Multiplayer:
Problems:

Notes