Keithley 708B Reference Manual page 217

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

Advertisement

Section 6: Instrument programming
Example: While
Code
list = {"One", "Two", "Three", "Four", "Five", "Six"}
print("Count list elements on numeric index:")
element = 1
while list[element] do
print(element, list[element])
element = element + 1
end
Repeat until loops
To repeat a command, you use the repeat ... until statement. The body of a repeat statement
always executes at least once. It stops repeating when the conditions of the until clause are met.
repeat
block
until expression
Where:
block consists of one or more Lua statements
expression is Lua code that evaluates to either true or false
Example: Repeat until
Code
list = {"One", "Two", "Three", "Four",
"Five", "Six"}
print("Count elements in list using repeat:")
element = 1
repeat
print(element, list[element])
element = element + 1
until not list[element]
For loops
There are two variations of for statements supported in Lua: numeric and generic.
In a for loop, the loop expressions are evaluated once, before the loop starts.
6-26
Models 707B and 708B Switching Matrix Reference Manual
Notes and output
This loop will exit when
list[element] = nil.
Count list elements on
1.000000000e+00
2.000000000e+00
3.000000000e+00
4.000000000e+00
5.000000000e+00
6.000000000e+00
Notes and output
Count elements in list using
repeat:
1.000000000e+00
2.000000000e+00
3.000000000e+00
4.000000000e+00
5.000000000e+00
6.000000000e+00
NOTE
numeric index:
One
Two
Three
Four
Five
Six
One
Two
Three
Four
Five
Six
707B-901-01 Rev. A / August 2010

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

707b

Table of Contents