User manual
Series 3700 System Switch/Multimeter Reference Manual Section 2: TSP Programming Fundamentals
3700S-901-01 Rev. C / July 2008 2-41
Output of code above:
Zero is true!
' if ' expression 2 was not false.
' if ' expression 3 was not false.
' if ' expression 4 was false.
x is not equal to 10, and y is not less than 2.
Loop control
TSL has familiar constructs for doing things repetitively or until an expression
evaluates to false.
The following code contains an example iteration:
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,")
print("in steps of two:")
for element = 1, 4, 2 do
print(element, list[element])
end
--
--------------- WHILE loop ---------------
--
-- Will exit when list[element] = nil
print("Counting elements in list")
print("on numeric index")
element = 1
while list[element] do
list[element] = nil
print(element, list[element])
element = element + 1
end