Fandom

Livecode Wiki

If

1,965pages on
this wiki
Add New Page
Comments0 Share

The IF structure is used to act when a condition is true, for example:

put 32 into myVar
if myVar = 32 then
  answer "Variable myVar is 32 now!"
end if

You can add also an ELSE option, look the following example:

if myVar = 32 then
  answer "Variable myVar is 32 now!"
else
  answer "Variable myVar is not 32, what is now?"
end if

You can nest if tests one inside another how may times you wish. For example:

if myVar = 32 then

  answer "Variable myVar is 32 now!"
else
  if myVar = 33 then
    answer "Variable myVar is 33 now!"
  else
    if myVar = 34 then
      answer "Variable myVar is 34 now!"
    else
      answer "Variable myVar is not 32,33 or 34; what is now?"
    end if
   end if
end if

However switch structure is more adapt to work with multiple tests.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.