Keithley 708B Reference Manual page 220

Switching matrix
Hide thumbs Also See for 708B:
Table of Contents

Advertisement

Models 707B and 708B Switching Matrix Reference Manual
Example: Break with infinite loop
Code
a, b = 0, 1
while true do
print(a,b)
a, b = b, a + b
if a > 500 then
break
end
end
Tables and arrays
Lua makes extensive use of the data type table, which is a flexible array-like data type. Table indices
start with 1. Tables can be indexed not only with numbers, but with any value (except nil). Tables
can be heterogeneous, which means that they can contain values of all types (except nil).
Tables are the sole data structuring mechanism in Lua; they may be used to represent ordinary
arrays, symbol tables, sets, records, graphs, trees, and so on. To represent records, Lua uses the
field name as an index. The language supports this representation by providing a.name as an easier
way to express a["name"].
Example: Loop array
Code
atable = {1, 2, 3, 4}
i = 1
while atable[i] do
print(atable[i])
i = i + 1
end
707B-901-01 Rev. A / August 2010
Section 6: Instrument programming
Notes
This example uses a break statement that
causes the while loop to exit if the value of a
becomes greater than 500.
Output:
0.0000000e+00
1.0000000e+00
1.0000000e+00
1.0000000e+00
1.0000000e+00
2.0000000e+00
2.0000000e+00
3.0000000e+00
3.0000000e+00
5.0000000e+00
5.0000000e+00
8.0000000e+00
8.0000000e+00
1.3000000e+01
1.3000000e+01
2.1000000e+01
2.1000000e+01
3.4000000e+01
3.4000000e+01
5.5000000e+01
5.5000000e+01
8.9000000e+01
8.9000000e+01
1.4400000e+02
1.4400000e+02
2.3300000e+02
2.3300000e+02
3.7700000e+02
3.7700000e+02
6.1000000e+02
Notes and output
Defines a table with four numeric elements.
Loops through the array and prints each
element.
The Boolean value of atable[index]
evaluates to true if there is an element at that
index. If there is no element at that index, nil
is returned (nil is considered to be false).
Output:
1.0000000e+00
2.0000000e+00
3.0000000e+00
4.0000000e+00
6-29

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

707b

Table of Contents