Sign in Join
Wiki copytemporary

Boolean: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Overview
22
33The [[simple type]] **boolean** is a logical [[Data type|data type]]. Data of type boolean has one of only two values, either [[True|true]] or [[False|false]]. A boolean [[Variable|variable]] is 1 byte in size.
44
55The `true` value can be assigned directly to a boolean variable or from the result of a comparison or test that was successful (`true`). Similarly the `false` value can be assigned directly or from the result of a comparison or test that was not successful (`false`). The [[Write]]() and Writeln() [[Procedure|procedures]] will print a [[String|string]] that corresponds to the value of a boolean variable (either "TRUE" or "FALSE"). A Boolean variable can be used as the expression in an [[If|if statement]]. The WriteStr() procedure can be used to store a string literal representing a boolean variable's value in a string variable.
66
77``` pascal
88program booleantest;
99var
1010 tooLarge : Boolean = false;
1111 boolString : ShortString;
1212begin
1313 Writeln(tooLarge);
1414 tooLarge := (0 = 0);
1515 Writeln(tooLarge);
1616 tooLarge := (3 > 5);
1717 Writeln(tooLarge);
1818 tooLarge := true;
1919 Writeln(tooLarge);
2020 if tooLarge then
2121 Writeln('tooLarge is true')
2222 else
2323 Writeln('tooLarge is false');
2424 WriteStr(boolString,tooLarge);
2525 Writeln(boolString);
2626end.
2727```
2828
2929Outputs:\
30-**FALSE**
3130
32-**`TRUE`**\
33-**`FALSE`**\
34-**`TRUE`**\
35-**`tooLarge is true`**\
36-**`TRUE`**
31+```
32+FALSE
33+TRUE
34+FALSE
35+TRUE
36+tooLarge is true
37+TRUE
38+```
3739
3840## See also
3941
4042- [[Boolean Expressions]]
4143
4244---
4345*From the Free Pascal wiki, page "Boolean", as it stood on 2020-10-14 after a change by Rfc1394, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history