typestar

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

  1. strswitch compares strings, case-insensitively by default.
  2. It closes with endswitch; there is no endstrswitch.
  3. break leaves the switch, so a case that returns needs no break.

Keywords and builtins used here

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.

Type this snippet

Step 4 of 4 in Flow control, step 11 of 18 in Language basics.

← Previous Next →