Used to conditionally execute a block of statements when some expression evaluates to true.
Syntax
if expression then
{ statement }...
[ elseif expression then
{ statement }... ]...
end
Notes
expression
|
the expression to evaluate.
|
statement
|
any statements to process.
|
Example
if quantity > 0 then
unitCost = totalAmount / quantity
print( "Unit Cost: " + unitCost )
elseif quantity = 0 then
print( "0 items ordered" )
elseif quantity < 0 then
print( quantity + "is not valid value" )
end
|