SWITCH Keyword

Purpose

Tests the value of an expression against a number of constant values and executes an associated expression based on the value that matches.

Syntax

<!-- #ICE [REPEAT]
            SWITCH=`switch_expression`
            CASE `constant1`=`result1`
            CASE `constant2`=`result2`
            …
            CASE `constantn`=`resultn`
            [DEFAULT=`default_result`]
-->


Description

The following table lists the parameters used with the SWITCH keyword:

 

Parameter

Description

switch_expression

The value you want to compare to the constant values.  It is usually an expression containing one or more variables.

constantn

A constant value to be compared to the switch_expression.

resultn

A resulting value.  It can be any markup text, including variables and Ingres/ICE macro commands.

default_result

The default resulting value, if none of the compared values match the switch_expression.

REPEAT Option                   See the FUNCTION keyword for information on the REPEAT option.

Example

The following example results in the string “Ingres II” appearing in the document if the variable product is set to “I”:

<!-- #ICE SWITCH= `:product`

   CASE `D`=`Unicenter TND`

   CASE `I`=`Ingres II`

   CASE `J`=`Jasmine`

   CASE `U`=`Unicenter TNG`

   DEFAULT=`CA product`

-->

See Also

IF keyword