User manual
Section 2: TSP Programming Fundamentals Series 3700 System Switch/Multimeter Reference Manual
2-40 3700S-901-01 Rev. C / July 2008
Branching
TSL uses the if keyword to do conditional branching.
--
--------------- IF blocks ---------------
--
-- This is if expression 1. Zero is true in Lua language;
this is a contrast to C language, where 0 evaluates
false. In TSL, nil is false and everything else is true.
if 0 then
print("Zero is true!")
else
print("Zero is false.")
end
x = 1
y = 2
-- This is if expression 2.
if (x and y) then
print("' if ' expression 2 was not false.")
end
-- This is if expression 3.
if (x or y) then
print("' if ' expression 3 was not false.")
end
-- This is if expression 4.
if (not x) then
print("' if ' expression 4 was not false.")
else
print("' if ' expression 4 was false.")
end
This is if expression 5.
if x == 10 then
print("x = 10")
elseif y > 2 then
print("y > 2")
else
print("x is not equal to 10, and y is not less than 2.")
end