6: Instrument programming Series 2600B System SourceMeter® Instrument
6-20 2600BS-901-01 Rev. B / May 2013
The syntax of a conditional block is as follows:
if expression then
block
elseif expression then
block
else
block
end
Where:
• expression is Lua code that evaluates to either true or false
• block consists of one or more Lua statements
Example: If
print("Zero is true!")
else
print("Zero is false.")
Zero is true!
Example: Comparison
y = 2
if x and y then
print("Both x and y are true")
Both x and y are true
Example: If and else
if not x then
print("This is from the if block")
else
print("This is from the else block")
This is from the else
block