×
Menu
Index

IF..THEN..ELSEIF..ELSE..END IF Keywords

 
Usage:
IF expression THEN
    statements
[ELSEIF expression2 THEN]
    statements
[ELSE]
    statements
END IF
 
Description:
Use the IF keyword to execute a block of statements only if a condition is true.
 
Optionally, you can also specify additional blocks that are executed only if the previous conditions are false and a new condition is true (ELSEIF), or that are executed only if all other blocks are false (ELSE).
 
Example:
sub main()
   a = 10
   b = 0
   c = 0
 
   if a > 5 then
      printl("a > 5")
   elseif b > 5 then
      printl("b > 5")
   elseif c > 5 then
      printl("c > 5")
   else
      printl("a, b, and c < 5")
   end if
   // note the following difference due to b being numeric variable
   if b="X" then
     print("b = 0")
   end if
 
   if "X"=b then
     print("X = b")
   end if 
end sub