Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?


Evaluate a set of conditions to determine which of several actions to perform.




Attribute or Element Description
name, disabled, xpos, ypos, xend, yend attributes See “Common Attributes and Elements.”
<annotation> element
<case> element Required (at least one). Each <case> element defines a condition that may or may not be true.
<default> element Optional. Specifies the action to take if no <case> condition is satisfied. If present, must appear last in the <switch> element.


The <switch> element contains a sequence of one or more <case> elements and an optional <default> element.

When a <switch> element is executed, it evaluates each <case> condition in turn. These conditions are logical expressions in the scripting language of the containing <process> element. If any expression evaluates to the integer value 1 (true), then the contents of the corresponding <case> element are executed; otherwise the expression for the next <case> element is evaluated.

If no <case> condition is true, the contents of the <default> element are executed.

As soon as one of <case> elements is executed, execution control leaves the surrounding <switch> statement. If no <case> condition matches, control leaves the <switch> after the <default> activity executes.

If no <case> is true and there is no <default>, no activity results from the <switch> statement.

Activities within a <case> element can be any BPL activity, including <assign> elements as in the example below:

<switch name='Approved?'>
  <case name='No PrimeRate' condition='context.PrimeRate=""'>
    <assign name='Not Approved' property="response.IsApproved" value="0"/>
  <case name='No Credit' condition='context.CreditRating=""'>
    <assign name='Not Approved' property="response.IsApproved" value="0"/>
  <default name='Approved' >
    <assign name='Approved' property="response.IsApproved" value="1"/>
    <assign name='InterestRate'
        <![CDATA[Copy InterestRate into response object.]]>