400 users using DBSP now!
home -> documentation -> environment guide -> Multiple choices: The CASE tag

Multiple choices: The CASE tag

The CASE tag enables you to select from multiple choices based on a set of Boolean expressions. Below is an example of the syntax:

<#CASE>
  <#OPTION EXPRESSION="expression1">
    …
  <#OPTION EXPRESSION="expression2">
    …
    …
  <#ELSE>
    …
<#/CASE>

The logic beyond the CASE consists in evaluating all the Boolean expressions in descending order, such that the first expression that evaluates to true will define the code block that will be executed instead of the complete CASE block. If any of the expressions evaluates to true and an ELSE block is defined, then the ELSE block is inserted instead.

Examples

Example 1. A basic CASE tag

This example shows the most basic use of the CASE Tag.

Source code
Test example


Example 2. A random CASE statement

This example shows another variant of the CASE Tag.

Source code
Test example

Previous | Next