Boolean
Deutsch · English · Français · Suomi · Русский · 中文(中国)
Overview
The simple type boolean is a logical data type. Data of type boolean has one of only two values, either true or false. A boolean variable is 1 byte in size.
The 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() procedures will print a 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 statement. The WriteStr() procedure can be used to store a string literal representing a boolean variable's value in a string variable.
program booleantest;
var
tooLarge : Boolean = false;
boolString : ShortString;
begin
Writeln(tooLarge);
tooLarge := (0 = 0);
Writeln(tooLarge);
tooLarge := (3 > 5);
Writeln(tooLarge);
tooLarge := true;
Writeln(tooLarge);
if tooLarge then
Writeln('tooLarge is true')
else
Writeln('tooLarge is false');
WriteStr(boolString,tooLarge);
Writeln(boolString);
end.Outputs:\
FALSE
TRUE
FALSE
TRUE
tooLarge is true
TRUESee also
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.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
