Documentation (c) 2006-2008 Hobby-Robotics, LLC
If Then statement is used to alter program execution based on the condition. Condition is a expression which is first converted to the Boolean type and then used to make a decision.
If Condition Then
...
End If
This the simples form of the If Then statement, it checks whether the Condition evaluates to Boolean value True and if it does executes statements between If and End If. If the Condition evaluates to False no statements are executed.
If Condition Then
...
Else
...
End If
In the more complex form the If Then checks whether the Condition evaluates to Boolean value True, if it does it executes statements between If and Else. If the Condition evaluates to Boolean value False statements between Else and End If will be executed.
If Condition1 Then
ElseIf Condition2 Then
...
ElseIf ConditionN Then
...
Else
...
End If
Third form of the If with multiple conditions checks whether the Condition1 evaluates to Boolean value True and if it does it executes statements between If and Else and then exists the If. If Condition1 is False then Condition2 of the first Elseif is evaluated, if that condition is False then following Elseif conditions are evaluated up to ConditionN, block of statements following the first True condition is executed and then If is exited. If no condition evaluates to True then statements between Else and End If will be executed. The Else block is optional. There is no limit on number of ElseIf parts.