Boolean Type

The Boolean type represents a logical value that can be either True or False.

Literals

The two standard boolean constants are True and False. They are case-insensitive in the source code but conventionally written in PascalCase.

// Type inference
var isReady := True;
var hasFinished := False;

// Explicit typing
var isValid : Boolean := True;
var isComplete : Boolean;
isComplete := False;

Operations

Booleans are used with logical operators: not, and, or, xor, and implies. All logical operators in DWScript are short-circuiting (evaluated left-to-right, stopping as soon as the result is determined).

var a := True;
var b := False;

var result := (a or b) and (not b); // True

// Implies: True implies False is False
var imp := a implies b;
PrintLn('Implies: ' + imp.ToString);
Result
Implies: False

Comparisons

Comparison operators (=, <>, <, >, <=, >=) result in a Boolean value.

var x := 10;
var y := 20;
var isGreater := x > y; // False

String Conversion

Booleans can be converted to strings using BoolToStr or the .ToString helper.

var b := True;
PrintLn(b.ToString); // "True"
PrintLn(BoolToStr(True)); // "True"
Result
True
True

Logic & Control

Booleans are the foundation of decision making.

See
Conditionals
for usage in if and case statements.

Or explore
Basic Operators
for logical operations like and, or, and not.

On this page