/
if statements
if statements
if statements are Block statements.
They allow us to run a piece of code if a condition is true. The condition is considered true if the value is anything other than false or nil.
local LabTest = true
if LabTest then
ProcessLabTest() -- this statement is executed
end
You can use Equality and Inequality Operators to create conditional logic. For instance:
local temperature = 98.6
if temperature == 98.6 then
trace("temperature is 98.6") -- this statement is executed
end
You can extend if statements further by using elseif and else to define additional conditions to check.
local temperature = 104
if temperature == 98.6 then
trace("temperature is 98.6")
elseif temperature > 98.6 and temperature < 100 then
trace("temperature is slightly above normal")
elseif temperature >= 100 then
trace("patient has a fever") -- this statement is executed
else
trace("temperature is below normal")
end
, multiple selections available,
Related content
Block statements
Block statements
More like this
Logical Operators
Logical Operators
More like this
while loop
while loop
More like this
for loop
for loop
More like this
Loops
More like this
Functions
Functions
More like this