OS/2 Procedures Language 2/REXX


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Logical Operators - Examples


The following procedure, AND.CMD, shows the AND operator checking for two 
true statements. 

/* Using the AND (&) Operator   */
/* 0 is false; 1 is true        */
a = 4
b = 2
c = 5
d = (a > b) & (b > c)
SAY 'The result of (a > b) & (b > c) is' d
d = (a > b) & (b < c)
SAY 'The result of (a > b) & (b < c) is' d
EXIT

When run on your system, AND.CMD displays the following on your screen as: 



[C:\]AND
The result of (a > b) & (b > c) is 0
The result of (a > b) & (b < c) is 1

[C:\]

The following procedure, OR.CMD, shows the OR operator in a true statement 
unless both values are false: 

/* Using the OR (|) Operator    */
/* 0 is false; 1 is true        */
a = 4
b = 2
c = 5
d = (a > b) | (b > c)
SAY 'The result of (a > b) | (b > c) is' d
d = (a > b) | (b < c)
SAY 'The result of (a > b) | (b < c) is' d
EXIT

When run on your system, the procedure displays the following: 


[C:\]OR
The result of (a > b) | (b > c) is 1
The result of (a > b) | (b < c) is 1

[C:\]
  

Inf-HTML End Run - Successful