EasyManuals Logo

Keithley SourceMeter 2600 Series User Manual

Keithley SourceMeter 2600 Series
594 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #108 background imageLoading...
Page #108 background image
2-56 TSP Programming Fundamentals Series 2600 System SourceMeters Reference Manual
2600S-901-01 Rev. A / May 2006 Return to Section 2 topics
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} -- A table with four elements, which are numbers.
Let's print it:
i = 1 -- 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.
while atable[i] do
print (atable[i]) -- Index into table using a number.
i = i + 1
end
Output of code above:
1
2
3
4
Tables can be indexed using element names instead of numeric indicies.
Since functions are 1st class variables, tables can be used to
create "pseudo-classes." Classes are often used in objec-oriented
programming.
Below is a table used to create a circle pseudo-class. It has 3 elements:
clr: a string containing the color of the circle
diam: a number containing the diameter of the circle
setdiam: a function, or method, used to change the diameter
circle = {clr = "red", diam = 1, setdiam = function(d)
circle["diam"]=d end}
print(circle["clr"]) -- Index using a string; print the clr property.
print(circle["diam"]) -- Index using a string; print the diam property.
circle["setdiam"](2) -- Change the diam element by calling setdiam method.
print(circle.diam) -- circle["diam"] is the same as circle.diam; simpler syntax
circle.setdiam(3) -- Change the diameter of the circle again.
print(circle.diam) -- Print diam property again using simple syntax.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Keithley SourceMeter 2600 Series and is the answer not in the manual?

Keithley SourceMeter 2600 Series Specifications

General IconGeneral
BrandKeithley
ModelSourceMeter 2600 Series
CategoryMeasuring Instruments
LanguageEnglish

Related product manuals