Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



Excerpt
hiddentrue

switch(\[condition1, result1\],\[condition2, result2\],...,\[conditionN, resultN\],defaultResult) Evaluates a set of conditions in turn, and returns the associated result for the first match.


Function: switch()

Evaluates a set of conditions in turn, and returns the associated result for the first match.

...

switch([condition1, result1],[condition2, result2],[,...,[conditionN, resultN]],defaultResult)

ArgumentTypeDescription
conditionNBooleanThe condition to be checked .
resultNStringResult to be returned if condition is True.
defaultResultStringIf no condition results in True, this is the default result to be returned.

Examples

switch( [startsWith(in.cli, "01223"), "Cambridge"], [startsWith(in.cli, "01604"), "Northampton"], "Elsewhere" )

This example shows how attribute in.cli, holding a telephone number, can be compared to a number of start codes and resolved to a destination. If none of the codes are matched, "Elsewhere" is the default destination returned.

Code Block
switch( 
   
   [startsWith(in.cli, "01223"), "Cambridge"], 
   [startsWith(in.cli, "01604"), "Northampton"], 

   "Elsewhere" 
)

Returns "Cambridge" if in.cli = "01223456765".

...