Boolean
From Team Developer SqlWindows Wiki
Revision as of 12:54, 12 September 2008 by 62.58.16.59 (Talk)
This page covers boolean datatype tips & tricks.
Contents |
How are expressions evaluated
Team Developer uses these precedence rules to evaluate expressions:
- Evaluate expressions with AND, OR, and NOT from left to right.
If bError OR bStop ! ! bError will be evaluated first, then bStop
- Stop evaluating AND/OR as soon as the result is known.
If bError OR bStop ! ! When bError is TRUE, bStop will not be evaluated ! When bError is FALSE, bStop will be evaluated ! If bError AND bStop ! ! When bError is TRUE, bStop will be evaluated ! When bError is FALSE, bStop will not be evaluated
- Evaluate expressions in parentheses first.
What is a boolean in TD ?
Internally, the boolean datatype is the same as the Number datatype.
The only difference between a Number and a Boolean is purely visual in the outline.
This means that you can assign any value to a Boolean, use them as it were normal numbers.
So beware, the next piece of code shows strange effects can happen when you are not aware of this
Set bValue = 5 If bValue = TRUE ... Else ! It evaluates to FALSE here If bValue ! It evaluates to TRUE here Else ...
So the best way to evaluate booleans is never use the TRUE or FALSE keywords.
If bValue ! when boolean has any (negative) value except FALSE, 0, NUMBER_Null Else ! when boolean is FALSE, 0 or NUMBER_Null