FutureBasic Logo

<<    Index    >> FutureBasic

∣∣ - logical 'or'   operator



Syntax
result = exprA ∣∣ exprB

Description
The logical ∣∣ operator evaluates both exprA's and exprB's for non-zero values. If either expression contains non-zero, result returns true, otherwise result returns false. Unlike FB's bitwise or operator, ∣∣ is a logical operator and probably the one most programmers would use.

Example
In the following example, expressions are evaluated as true or false before a decision is made for branching. The logical expression age ⩵ 21 is true, and is therefore evaluated as true. The expression age ⩵ 22 is false, and is therefore evaluated as false. Then the logical comparison (true) ∣∣ (false) is performed, resulting in true ( because one operand's content is non-zero). Finally, the if statement interprets this non-zero result as meaning "true," and executes the first print statement.

Note: since one of the conditions is true the other does not need to be evaluated. In other words, if the first condition is true the second condition is not evaluated.

age = 21
if ( age ⩵ 21 ∣∣ age ⩵ 22 )
   print "Congratulations!"
else
   print "Sorry. you must be 21 or 22 years of age to qualify!"
end if


Example Two
JoeIsHere = 16
FredIsHere = 0
if JoeIsHere ∣∣ FredIsHere
  print "One of them is here!"
else
  print "Neither one is here!"
end if


program output:
  One of them is here!

See also
and; nand; nor; not; xor; or; Appendix D - Numeric Expressions