typestar

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

  1. switch compares numbers and closes with endswitch.
  2. A case without break falls through, which is sometimes the point.
  3. default catches everything else and is worth writing.

Keywords and builtins used here

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.

Type this snippet

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

← Previous Next →