typestar

Conditions in Igor Pro

if/elseif/else, and the ternary operator for the small cases.

Function Grade(Variable score)
    if (score >= 90)
        return 3
    elseif (score >= 70)
        return 2
    elseif (score > 0)
        return 1
    else
        return 0
    endif
End

Function Clip(WAVE w, Variable limit)
    w = w > limit ? limit : w
End

How it works

  1. Every if needs an endif, even a one-line one.
  2. Igor has no booleans: zero is false and anything else is true.
  3. ?: is an expression, so it works inside a wave assignment.

Keywords and builtins used here

The run, in numbers

Lines
15
Characters to type
207
Tokens
54
Three-star pace
75 tpm

At the three-star pace of 75 tokens a minute, this run takes about 43 seconds.

Type this snippet

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

← Previous Next →