Keithley 2601B Reference Manual page 300

2600b series system sourcemeter instrument
Hide thumbs Also See for 2601B:
Table of Contents

Advertisement

Series 2600B System SourceMeter® Instrument Reference Manual
Example: Numeric for
list = {"One", "Two", "Three", "Four", "Five", "Six"}
---------- For loop -----------
print("Counting from one to three:")
for element = 1, 3 do
print(element, list[element])
end
print("Counting from one to four, in steps of two:")
for element = 1, 4, 2 do
print(element, list[element])
end
The numeric for loop repeats a block of code while a control variable runs through an
arithmetic progression.
Output:
Counting from one to three:
1
One
2
Two
3
Three
Counting from one to four, in steps of two:
1
One
3
Three
Example: Generic for
days = {"Sunday",
"Monday",
"Wednesday",
"Friday",
for i, v in ipairs(days) do
print(days[i], i, v)
end
The generic for statement works by using functions called iterators. On each iteration, the
iterator function is called to produce a new value, stopping when this new value is nil.
Output:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
2600BS-901-01 Rev. B / May 2013
"Tuesday",
"Thursday",
"Saturday"}
1
Sunday
2
Monday
3
Tuesday
4
Wednesday
5
Thursday
6
Friday
7
Saturday
Section 6: Instrument programming
6-23

Advertisement

Table of Contents
loading

This manual is also suitable for:

2604b2614b2634b2635b2636b2602b ... Show all

Table of Contents