Series 2600 System SourceMeters Reference Manual TSP Programming Fundamentals 2-55
Return to
2600S-901-01 Rev. A / May 2006
Functions
TSL allows you to define functions. A function can take a predefined number of
parameters and return multiple parameters if desired.
Let's define a function and call it:
function add_two(parameter1, parameter2)
return(para parameter2)
end
print(add_two(3, 4))
Below is an alternate syntax for defining a function. Functions are
first-class values in TSL, which means functions can be stored in
variables, passed as arguments, and returned as results if desired.
add_three = function(parameter1, parameter2, parameter3)
return(para para parameter3)
end
print(add_three(3, 4, 5))
Here is a function that returns multiple parameters; sum, difference, and ratio
of the two numbers passed to it:
function sum_diff_ratio(parameter1, parameter2)
psum = para parameter2
pdif = parameter1 – parameter2
prat = parameter1 / parameter2
return psum, pdif, prat
end
sum, diff, ratio = sum_diff_ratio(2,3)
print(sum)
print(diff)
print(ratio)
Output of code above:
7
12
5
-1
0.66666
Summary of Contents for SourceMeter 2600 Series
Page 575: ...AppendixF DisplayCharacterCodes Appendix F topics Introduction page F 2...
Page 592: ......
Page 593: ......