Switch statement

Is there a switch statement in eggPlant or something equivilent?

ex.
// x = state of a test; 0 = test failed, 1 = test passed,
switch x {
case 0:
put “Test failed”
break
case 1:
put “Test passed”
break
default:
put “Test not run!”
break
}

Hello, RoundhillMark–

There is no switch/case structure currently available in SenseTalk. You would have to accomplish it with if/else if/else.

if x is equal to 0
  put "passed"
else if x is equal to 1
  put "failed"
else
  put "test not run"
end if

I will pass that request along to the developers. Thanks!

In the eight years since this was first posted, is there yet a more elegant solution than a long string of if…then…else statements. I have a switch with nearly a dozen cases that I have to evaluate.

Thanks!