Functions in Igor Pro
A function declares what it returns before its name, and closes with End.
Function Area(Variable radius)
return pi * radius^2
End
Function/S Describe(Variable radius)
return "circle of area " + num2str(Area(radius))
End
Function/WAVE Ramp(Variable n)
Make/O/N=(n)/D/FREE out = p
return out
End
How it works
Functionwith no type suffix returns a number.Function/Sreturns a string andFunction/WAVEreturns a wave reference.- Parameters are declared with their types, in the parentheses or below.
Keywords and builtins used here
AreaEndFunctionMakeVariablenum2strpireturn
The run, in numbers
- Lines
- 12
- Characters to type
- 221
- Tokens
- 53
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 45 seconds.
Step 2 of 3 in Variables & functions, step 6 of 18 in Language basics.