If
See Also: Miscellaneous Functions, Boolean, Case, For, Repeat, Until, While, If command
Purpose
Evaluates a Boolean expression, then returns the value of one of two other expressions depending on the Boolean result.
Return Type
Syntax
(If( {BooleanExpression}, {TrueExpression}, {FalseExpression} ))
Where:
- {BooleanExpression} is the test that is performed to determine which of the following expressions will be performed.
- {TrueExpression} is the value that will be returned if the Boolean result is True.
- {FalseExpression} is the value that will be returned if the Boolean result is False.
What It Does
Returns {TrueExpression} if {BooleanExpression} evaluates to True and {FalseExpression} if {BooleanExpression} evaluates to False.
Integer iHome iVisitors
Showln(If(iHome > iVisitors, "we won!", "they won."))
In this example, if the value of variable iHome is greater than that of variable iVisitors, the constant "we won!" is shown. If it is not, the constant "they won." is shown.
Notes
- If the {BooleanExpression} is zero or blank, the {FalseExpression} is returned. If it is not zero or blank, {TrueExpression} is returned.