DelphiBasics
 OrKeyword Boolean or or bitwise or of two arguments
 1 Boolean expression or Boolean expression 2 Integer expression or Integer expression
Description
The Or keyword is used in two different ways:

1. To perform a logical or boolean 'or' of two logical values. If either are true, then the result is true, otherwise it is false.

2. To perform a mathematical 'or' of two integers. The result is a bitwise 'or' of the two numbers. For example:

10110001 Or 01100110 = 11110111
Notes
If the boolean expression is calculated (as opposed to being a Boolean variable), then brackets are required to isolate it.
Related commands
 And Boolean and or bitwise and of two arguments Not Boolean Not or bitwise not of one arguments Xor Boolean Xor or bitwise Xor of two arguments
Author links

Buy Website Traffic at
Buywebsitetrafficexperts.com

Buy Proxies at
Buyproxies.io

Download this web site as a Windows program.

 Example code : Illustrate both types of or usage // Full Unit code.// -----------------------------------------------------------// You must store this code in a unit called Unit1 with a form// called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses  Forms, Dialogs; type  TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);  end; var  Form1: TForm1; implementation{\$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var   num1, num2, num3 : Integer;   letter           : Char; begin  num1   := \$25;    // Binary value : 0010 0101   \$25  num2   := \$32;    // Binary value : 0011 0010   \$32                    // Or'ed value  : 0011 0111 = \$37   letter := 'G';   // And used to return a Boolean value   if (num1 > 0) Or (letter = 'G')   then ShowMessage('At least one value is true')   else ShowMessage('Both values are false');   // And used to perform a mathematical OR operation   num3 := num1 Or num2;   // Display the result   ShowMessageFmt('\$25 or \$32 = \$%x',[num3]); end; end. Hide full unit code At least one value is true   \$25 or \$32 = \$37
 Delphi Programming © Neil Moffatt 2002 - 2018. All rights reserved.  |  Home Page