SPC
Version 0.9.5
|
Comparing two expressions forms a condition.
A condition may be negated with the logical negation operator, or two conditions combined with the logical AND and logical OR operators. Like most modern computer languages, SPC supports something called "short-circuit" evaluation of conditions. This means that if the entire value of the conditional can be logically determined by only evaluating the left hand term of the condition, then the right hand term will not be evaluated.
The table below summarizes the different types of conditions.
Condition | Meaning |
---|---|
Expr | true if expr is not equal to 0 |
Expr1 == expr2 | true if expr1 equals expr2 |
Expr1 != expr2 | true if expr1 is not equal to expr2 |
Expr1 < expr2 | true if one expr1 is less than expr2 |
Expr1 <= expr2 | true if expr1 is less than or equal to expr2 |
Expr1 > expr2 | true if expr1 is greater than expr2 |
Expr1 >= expr2 | true if expr1 is greater than or equal to expr2 |
! condition | logical negation of a condition - true if condition is false |
Cond1 && cond2 | logical AND of two conditions (true if and only if both conditions are true) |
Cond1 || cond2 | logical OR of two conditions (true if and only if at least one of the conditions are true) |
There are also two special constant conditions which can be used anywhere that the above conditions are allowed. They are listed below.
You can use conditions in SPC control structures, such as the if-statement and the while or until statements, to specify exactly how you want your program to behave.