Tables/Arrays - Keithley 3700 series Reference Manual

System switch/multimeter
Hide thumbs Also See for 3700 series:
Table of Contents

Advertisement

Section 2: TSP Programming Fundamentals
5
-1
0.66666

Tables/arrays

TSL makes extensive use of the data type ―table,‖ which is essentially a very flexible array-like
data type.
Define a table:
atable = {1, 2, 3, 4}
Send the following command to print it:
i = 1
while atable[i] do
print (atable[i])
i = i + 1
end
Output of code above:
1
2
3
4
Tables can be indexed using element names instead of numeric indices. Since functions are 1st
class variables, tables can be used to create "pseudo-classes." Classes are often used in
object-oriented programming.
Below is a table used to create a circle pseudo-class. It has 3 elements:
clr:
diam:
setdiam:
circle = {clr = "red", diam = 1, setdiam = function(d)
circle["diam"]=d end}
2-26
a string containing the color of the circle
a number containing the diameter of the circle
a function, or method, used to change the diameter
Series 3700 System Switch/Multimeter Reference Manual
A table with four elements, which are numbers.
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.
Index into table using a number.
Document Number: 3700S-901-01 Rev. A / August 2007

Advertisement

Table of Contents
loading

Table of Contents