Difference between revisions of "OR (boolean)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
imported>SMcNeill
(style guidelines)
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
The '''OR''' coditional operator adds an alternative in a [[IF...THEN]] or [[Boolean]] statement.
+
The '''OR''' conditional operator evaluates an expression to true (-1) if any of the arguments is also true.
  
  
 +
{{PageSyntax}}
 +
: [[IF]] {{Parameter|expression1}} '''OR''' {{Parameter|expression2}} THEN {code}
  
* OR adds an alternative to another conditional evaluation. IF True then the statement evaluation is True.
 
* Parenthesis may be used to clarify an evaluation.
 
  
 +
{{PageDescription}}
 +
* OR adds an alternative to another conditional evaluation. If either element in the evaluation is true then the evaluation is true.
 +
* Parenthesis may be used to clarify the order of comparisons in an evaluation.
 +
* Not to be confused with the [[AND]] and [[OR]] numerical operations.
  
''Example:''
 
  
:a% = 100
+
{{Template:RelationalTable}}
:b% = 50
 
  
: IF (a% > b% AND a% < 100) OR b% = 50 THEN PRINT "True"
 
  
 +
{{PageExamples}}
 +
''Example:''
 +
{{CodeStart}}
 +
a% = 100
 +
b% = 50
  
''Screen results:'' True
+
IF (a% > b% AND a% < 100) OR b% = 50 THEN PRINT "True"
 
+
{{CodeEnd}}
 
+
{{OutputStart}}
''Explanation:'' The first evaluation was False, but the OR evaluation made the statement true and the code was executed.
+
True
 
+
{{OutputEnd}}
 
+
: ''Explanation:'' The first evaluation was False, but the OR evaluation made the statement true and the code was executed.
 
 
''See also:'' [[AND (boolean)]]
 
 
 
  
  
==Navigation:==
+
{{PageSeeAlso}}
 +
* [[AND]], [[OR]] {{text|(logical operators)}}
 +
* [[AND (boolean)]], [[XOR (boolean)]]
 +
* [[IF...THEN]]
  
[[Keyword_Reference_-_Alphabetical|Go to Keyword Reference - Alphabetical]]
 
  
[[Keyword Reference - By usage|Go to Keyword Reference - By usage]]
+
{{PageNavigation}}

Latest revision as of 02:21, 17 October 2017

The OR conditional operator evaluates an expression to true (-1) if any of the arguments is also true.


Syntax

IF expression1 OR expression2 THEN {code}


Description

  • OR adds an alternative to another conditional evaluation. If either element in the evaluation is true then the evaluation is true.
  • Parenthesis may be used to clarify the order of comparisons in an evaluation.
  • Not to be confused with the AND and OR numerical operations.


Relational Operators:
Symbol Condition Example Usage
<  Less than  IF a < b THEN
>  Greater than  IF a > b THEN
=  Equal  IF a = b THEN
<=  Less than or equal  IF a <= b THEN
>=  Greater than or equal  IF a >= b THEN
<>  NOT equal  IF a <> b THEN


Examples

Example:

a% = 100 b% = 50 IF (a% > b% AND a% < 100) OR b% = 50 THEN PRINT "True"

True

Explanation: The first evaluation was False, but the OR evaluation made the statement true and the code was executed.


See also



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page