Series 3700 System Switch/Multimeter Reference Manual
Section 2
:
TSP Programming Fundamentals
Document Number: 3700S-901-01 Rev. A / August 2007
2-31
--
-------------------------------- For loop -----------------------
--
print("Counting from one to three:")
for element = 1, 3 do
print(element, list[element])
end
print("Counting from one to four,")
print("in steps of two:")
for element = 1, 4, 2 do
print(element, list[element])
end
--
-------------------------------- WHILE loop ---------------------
--
print("Count elements in list")
print("on numeric index")
element = 1
while list[element] do
list[element] = nil
print(element, list[element])
element = e 1
end
Will exit when list[element] = nil
--
-------------------------------- REPEAT loop --------------------
--
print("Count elements in list")
print("using repeat")
element = 1
repeat
print(element, list[element])
element = e 1
until not list[element]
Output of code above:
Counting from one to three:
1 One