switch in Igor Pro
A numeric switch, where a case without break falls into the next one.
Function/S ModeName(Variable mode)
switch (mode)
case 0:
return "lines"
case 1:
return "markers"
case 2:
case 3:
return "bars"
default:
return "unknown"
endswitch
End
How it works
switchcompares numbers and closes withendswitch.- A
casewithoutbreakfalls through, which is sometimes the point. defaultcatches everything else and is worth writing.
Keywords and builtins used here
EndFunctionVariablecasedefaultendswitchreturnswitch
The run, in numbers
- Lines
- 13
- Characters to type
- 166
- Tokens
- 35
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 28 seconds.
Step 3 of 4 in Flow control, step 10 of 18 in Language basics.