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
- Every
ifneeds anendif, even a one-line one. - Igor has no booleans: zero is false and anything else is true.
?:is an expression, so it works inside a wave assignment.
Keywords and builtins used here
EndFunctionVariableWAVEelseelseifendififlimitreturn
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.
Step 1 of 4 in Flow control, step 8 of 18 in Language basics.