strswitch in Igor Pro
The same shape for strings — and note it still closes with endswitch.
Function Apply(String action)
Variable code = -1
strswitch (action)
case "clear":
code = 0
break
case "reset":
code = 1
break
default:
Print "unknown action:", action
endswitch
return code
End
How it works
strswitchcompares strings, case-insensitively by default.- It closes with
endswitch; there is noendstrswitch. breakleaves the switch, so a case that returns needs no break.
Keywords and builtins used here
EndFunctionPrintStringVariablebreakcasedefaultendswitchreturnstrswitch
The run, in numbers
- Lines
- 16
- Characters to type
- 194
- Tokens
- 39
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 31 seconds.
Step 4 of 4 in Flow control, step 11 of 18 in Language basics.