
19-8
Return to
2600AS-901-01 Rev. B / September 2008
Section 19: Remote Commands
Series 2600A System SourceMeter® Instruments Reference Manual
print("x is not equal to 10, and y is not less than 2.")
end
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 and/or until an expression evaluates to
false.
-- Something to iterate
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 --------------------------
--
print("Count elements in list")
print("on numeric index")
element = 1
-- Will exit when list[element] = nil
while list[element] do
print(element, list[element])
element = e 1
end
--
-------------------------------- 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