Scripting in StreamServe > StreamServe scripting language specifics > Conditional statements > The switch...case statement

The switch...case statement
Use the switch...case statement when there are several different statements, or groups of statements, where it would be confusing to use a large number of "ifs" and "elses".
Syntax
switch (expression)
{
case value1:
statement1;
[break;]
case value2:
statement2;
[break;]
case valueN:
statementN;
[break;]
[default:
defaultStatement;]
}
The expression is tested, and depending on the value, the corresponding case is executed. If there is no corresponding case, the default case is executed.
A common error when using the switch...case statement is to forget that the execution starts in the selected case, and continues until break. If you leave out break, the execution will continue into the next case.
Examples
Example 25
switch ($countryCode)
{
case "USA":
$overlay = "invoiceUSA.lxf"
break;
case "Canada":
$overlay = "invoiceCanada.lxf";
break;
case "UK":
$overlay = "invoiceUK.lxf"
break;
default:
$overlay = "invoiceDefault.lxf"
}
 
OpenText StreamServe 5.6 Updated: 2013-03-01