DADiSP Worksheet Functions > Function Categories > Control Flow > SWITCH
Transfers control to one of several statements depending on the value of an expression.
switch (expr) statements
expr |
- |
Any expression resolving to a number or string. |
statements |
- |
One or more valid expressions separated by semicolons. |
The result of evaluating statements.
test(10) == 1
test("text") == 2
test(3) == 0
Unlike C/C++, expression may evaluate to an integer, real or string value. The statement is typically compound and is labeled with a case prefix as follows:
case constant-expression:
Each case constant must be unique. The optional default labeled statement is executed if expression does not compare to any case constant.