Allows just True and False values System unit
  type Boolean = (False, True);
The Boolean type provides an enumeration of the logical True and False values.
Unlike other languages, it is not a number - it will only allow these values. This makes the code much more reliable.
Using calculations to test for true or false is a C like practice, but is supported in Delphi. Use the following to hold such a logical number:


Related commands
And Boolean and or bitwise and of two arguments
If Starts a conditional expression to determine what to do next
Not Boolean Not or bitwise not of one arguments
Or Boolean or or bitwise or of two arguments
Xor Boolean Xor or bitwise Xor of two arguments
 Author links

 Download this web site as a Windows program.

Example code : Boolean assignments and tests
  same : Boolean;
  small, large, i : Integer;

  small := 23;
  large := 455555;

  // Test directly to see if these numbers are the same size
  if small = large
  then ShowMessage('small = large')
  else ShowMessage('small <> large');

  // Use a Boolean to hold and test this outcome
  same := (small = large);
  if same
  then ShowMessage('small = large')
  else ShowMessage('small <> large');

  // Assign a direct logical value to this Boolean
  same := True;
  if same
  then ShowMessage('same is True')
  else ShowMessage('same is False');
Show full unit code
   small <> large
   small <> large
   same is True
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page