Conditions
Previous Top Next

As of version 5.00 Basic4ppc supports more complex condition expressions.
Two binary operators are supported: AND and OR, and one unary operator is supported: NOT.
A simple condition expression must be evaluated to the boolean values: true or false.
The simple conditions can be combined into a more complex condition using the logical operators and using parenthesis.
Conditions are "short-circuit" conditions. Which means that the expressions will only be evaluated if they can affect the result.
For example: If StrLength(TextBox1.Text) > 4 AND StrAt(TextBox1.Text,4) = "a" Then msgbox(true).
The second condition will only evaluate if the first condition is true.
There are two benefits: it is faster as only the necessary expressions are evaluated and more important (like in this example) the second expression would have caused an error if it was evaluated when the first expression in not true.

Boolean values can be used directly.
Example: If Button1.Enabled then ...
Example: If True then ...

The NOT operator must be followed by parenthesis.
Example: If NOT (a = b OR a = b/2) Then ...
Example: If NOT (Button1.Enabled) Then ...