Or
Operand Or Operand
 
Parameters: NONE
Returns: NONE
 

      The Or operator performs a logical (bitwise) Or on the two specified operands.


           OR RULE

           1 or 1 = 1
           1 or 0 = 1
           0 or 1 = 1
           0 or 0 = 0

      So when we OR a pair of bits, we get a ONE result when either or both bits are set(one), we can only get a zero, when both are zero.

      OR is most commonly used within IF decisions where we want to ensure that at least one (or more) expressions are true (1) before executing the code inside.

  
  
; Create two variables
  A=100
  B=200
  
  
; Use OR to detect selective execute the code
; inside the IF.   The OR will merges the
; expression conditions, so as long as one
; side of the expression is TRUE (1)
; it'll run the code inside the IF/ENDIF
  
  
  If A=100 Or B=123456
     Print "A either ='s 100 or B ='s 123456"
  EndIf
; In this, the first expression is TRUE, and Second
; is FALSE.  The OR rule will merge these states
; and RETURN TRUE.  Making the IF statement run the
; code inside.
  
  
; Here we're swapping the expression around.
  If A=123456 Or B=200
     Print "either A ='s 100 or B ='s 200"
  EndIf
  
; IN this IF, the First exporession is FALSE
; and the second is TRUE.  When these states
; are Or'ed together, we get a TRUE and iot runs
; the code in the if/endif
  
  
  
  Sync
  WaitKey
  
  





FACTS:


      * Instead of the keyword Or you can use the symbol | there's also a short cut version of the operator |=

      * Most graphics rendering commands include Or blending rules. To set use InkMode





Mini Tutorial:


indent] Bitwise operations And, and Xor


  
; bitwise And
  Print Bin$(43+ " And" : Print Bin$(58+ " ="
  Print Bin$(43 And 58)
  Print ""
  
; bitwise Or
  Print Bin$(43+ " Or" : Print Bin$(58+ " ="
  Print Bin$(43 Or 58)
  Print ""
  
; bitwise Xor
  Print Bin$(43+ " Xor" : Print Bin$(58+ " ="
  Print Bin$(43 Xor 58)
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  %00000000000000000000000000101011 And
  %00000000000000000000000000111010 =
  %00000000000000000000000000101010
  
  %00000000000000000000000000101011 Or
  %00000000000000000000000000111010 =
  %00000000000000000000000000111011
  
  %00000000000000000000000000101011 Xor
  %00000000000000000000000000111010 =
  %00000000000000000000000000010001
  
  

 
Related Info: And | Comparisons | Not | NotInt | Operators | Xor :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com