If Statement

An if statement tests a condition to see if it is 0 (false) or non-zero (true) and then executes the appropriate series of statements. There may be optional elsif and else clauses. e.g.
    if a < b then
        x = 1
    end if
    if a = 9 and find(0, s) then
        x = 4
        y = 5
    else
        z = 8
    end if
    if char = 'a' then
        x = 1
    elsif char = 'b' or char = 'B' then
        x = 2
    elsif char = 'c' then
        x = 3
    else
        x = -1
    end if
Notice that elsif is a contraction of else if , but it is cleaner because it does not require an end if to go with it. There is just one end if for the entire if statement, even when there are many elsifs contained in it.

Obviously, "end if" (or "end for", "end while", "end switch", "end function", "end procedure", or "end type") is more typing than "}", but getting a compiler error message bang on the source code line where you slipped up easily makes up for that.
True story: I once dropped a single "}" sometime during a marathon refactoring (ten days with no compiling until every last class updated) of a large C++ program - the compiler then threw me a meaningless error in a completely unrelated file, and it took another three whole days just to track that compilation error down. Having half-decent syntax colouring in the code editor of the IDE I was forced to use might well have helped, but finding out that the compiler did not even count/check that brackets balanced properly in every source file was a real shocker for me.
The if and elsif conditions are tested using short-circuit evaluation.