User manual

Section 2: TSP Programming Fundamentals Series 3700 System Switch/Multimeter Reference Manual
2-36 3700S-901-01 Rev. C / July 2008
This function returns multiple parameters (sum, difference, and ratio of the two
numbers passed to it):
function sum_diff_ratio(parameter1, parameter2)
psum = parameter1 + 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)
The function's output is:
7
12
5
-1
0.66666
Tables/arrays
TSL makes extensive use of the data type "table," which is a very flexible array-
like data type.
To define a table:
-- A table with four elements, which are numbers.
atable = {1, 2, 3, 4}
Send the following commands to print it:
-- Tables are indexed on one, NOT zero. atable[index] is
true if there is an element at that index. nil is
returned otherwise. 0 does NOT evaluate to false, only
nil does.
i = 1
Index into table using a number.
while atable[i] do
print (atable[i])
i = i + 1
end
The command's output is:
1
2
3
4