switch(val1 val2 ...)

<< Click to Display Table of Contents >>

Navigation:  IWML > Data Binding > Modifiers >

switch(val1 val2 ...)

Switch is a one way modifier and converts boolean or numeric values into strings or enums.

 

Boolean

 

switch(trueval falseval)

 

Returns trueval if input is true, else returns falseval.

 

In this example, the switch modifier will return Yes or No.

 

=.Vendors.Active:switch(Yes No)

 

Number

 

switch(val0 val1 val2 ...)

 

If the input is a number the values will be indexed from zero:

 

=.Vendors.Code:switch(Zero One Two Three)

 

Counting always begins at 0. If a value for 0 is not needed, simply fill in a dummy value to occupy the space as a placeholder. The value can be anything, it will be ignored if 0 is never an input:

 

=.Vendors.Code:switch(invalid One Two Three)

 

Spaces in Values

 

Values with spaces can be handled by surrounding in parenthesis. In this example, the switch modifier returns Active or Not Active:

 

=.Vendors.Active:switch(Active (Not Active))

 

Example

 

In IntraWeb, Display is not a simple boolean as it supports Show, Hide, or Collapse. This would normally make binding to a boolean difficult, but with the switch modifier.

 

Text [b:Control Property]

checkbox:CB1 Click Me

Text

 Text: Hello

 Display: =this.CB1.Checked:switch(Show Hide)

]

 

Unchecked

 

clip0114

Checked

 

clip0115