FANDOM


The switch$ keyword is used to control the flow of a script. The general form of a switch statement is as follows:

switch (expression)
{
case string_value0:
statement(s);
break;
case string_value1;
statement(s);
break;
. . .
case string_valueN;
statement(s);
break;
default:
statement(s);
}

Where expression is evaluated and subsequently compared to the following case values. If a case string_value matches the evaluated expression, the statement(s) associated with that case are executed. If no values match and a default statement exists, the statement(s) in the default case will be executed.

switch$ is used ONLY for expressions that evaluate to a string value.

Note: Unlike C/C++, the break statements in switches are superfluous. Torque Script will only execute matching cases and NOT automatically execute all subsequent cases.

%tmp = "hi" ;

switch$( %tmp )
{
case "bye":
echo( "bye" );
case "hi":
echo ( "hi" );
}

Switch$

See Also Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.