next up previous contents index
Next: Arrays Up: Data types Previous: Character types

Booleans

Free Pascal supports the Boolean type, with its two pre-defined possible values True and False. These are the only two values that can be assigned to a Boolean type. Of course, any expression that resolves to a boolean value, can also be assigned to a boolean type.

Assuming B to be of type Boolean, the following are valid assignments:

 B:=True;
 B:=False;
 B:=1<>2;  { Results in B:=True }
Boolean expressions are also used in conditions.

Remark: In Free Pascal, boolean expressions are always evaluated in such a way that when the result is known, the rest of the expression will no longer be evaluated (Called short-cut evaluation). In the following example, the function Func will never be called, which may have strange side-effects.

 ...
 B:=False;
 A := B and Func;
Here Func is a function which returns a Boolean type.

Remark: The wordbool, longbool and bytebool were not supported by Free Pascal until version 0.99.6.



Michael Van Canneyt
Thu Sep 10 14:02:43 CEST 1998