# If / IIf

Value = If ( Boolean , True value [ , False value ] )

Evaluate the Boolean expression, and return True value if this expression is true, or False value if this expression is false.

If False value is not specified, it is assumed to be `NULL` .

Be careful! Contrary to IF, or the C/Perl ? operator, both True value and False value are evaluated, whatever the value of Boolean is.

Example

    X = 7

    PRINT If((X MOD 2) = 0, "Pair", "Impair")

    Impair

    ' Never do the following in real code, because it is not translatable!
    PRINT "You have " & X & " message" & If(X <> 1, "s") & " waiting."

    You have 7 messages waiting.

    PRINT If((X MOD 2) = 1, "Impair", 1 / 0)

    ** Division by zero **

Previous: IF Next: INC