[Switch Value]Series of [Case]...[/Case]
- New in 4.0
Executes the WebDNA inside
the only [Case] context which matches the given value.
To display some HTML (or execute some WebDNA) from a list of
known text options, put the text value inside a [Switch] context.
For each possible option, put a [Case]
context inside the [Switch]. You may optionally specify a default
case by inserting a [Default]
context. The [Default] context must be the very last context
inside the [Switch].
Example (normally you would put the following text into
a .tpl file on your server and use a web browser to link to it):
The value of x was 1
The value of x was 2
The value of x was neither 1 nor 2; it was [x]
You're a male
You're a female
In the first example above, the text "The value of x was
neither 1 nor 2; it was 5" will display, because the two
cases for "1" and "2" did not match the actual
value of x, which was "5." In the second example above,
the text "You're a female" will display. Any WebDNA
inside the other [Case] contexts will not execut, and any text
inside those contexts will not display.
- Note: The values are compared as case-insensitive
text only. This means the number "1.0" is not the same
as the number "1" when determining which of the [Case]
contexts to execute.