Updated: September 21, 2011
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
The boolean data type contains a value that evaluates to either true or false. You can use the X++ reserved literals true and false where ever a Boolean expression is expected.
Boolean expressions are also named logical expressions.
Boolean Values are Represented as Integers
In X++ the internal representation of a boolean is an integer. You can assign any integer value to a variable declared of type boolean. The integer value 0 (zero) evaluates to false, and all others evaluate to true.
The X++ literal false is the integer value 0, and true is 1.
The following table lists several expressions and indicates whether they evaluate to true or false.
|
Expression |
Boolean value |
|---|---|
|
1 |
True |
|
44 |
True |
|
true |
True |
|
(false == 0) |
True |
|
(true == 1) |
True |
|
(true == 8) |
False |
|
false |
False |
|
0 |
False |
Declaring Booleans
|
Boolean declaration |
= |
boolean variable { , variable } ; |
|
variable |
= |
identifier [ option ] |
|
option |
= |
Arrayoptions | initialization |
Automatic Conversions
Using Booleans in Expressions
You usually use Booleans in conditional statements, or as parts or results of logical expressions. The following example shows both.
Here, the variable exprValue contains the value true, because 7*6 is equal to 42; so, the expression is true. The conditional statement is true; the word "OK" is displayed on the screen.