Sign in Join
Wiki copytemporary

Boolean: what changed

Revision 2 to 3. 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:\
3030
31-```
31+```text
3232FALSE
3333TRUE
3434FALSE
3535TRUE
3636tooLarge is true
3737TRUE
3838```
3939
4040## See also
4141
4242- [[Boolean Expressions]]
4343
4444---
4545*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