OS/2 Procedures Language 2/REXX


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


The Logical Operators, NOT, AND, OR


Logical operators can return only the values of 1 or 0.  The NOT operator 
(¬ or \) in front of a term reverses its value either from true to false 
or from false to true. 

SAY  \ 0         /* gives '1'         */
SAY  \ 1         /* gives '0'         */
SAY  \ (4 = 4)   /* gives '0'         */
SAY  \ 2         /* gives  a  syntax error      */

The AND operator (&) between two terms gives a value of true only if both 
terms are true. 


SAY ( 3 = 3 ) & ( 5 = 5 )   /* gives '1'                     */
SAY ( 3 = 4 ) & ( 5 = 5 )   /* gives '0'                     */
SAY ( 3 = 3 ) & ( 4 = 5 )   /* gives '0'                     */
SAY ( 3 = 4 ) & ( 4 = 5 )   /* gives '0'                     */

The OR operator ( | ) between two terms gives a value of true unless both 
terms are false. 
Note:    Depending upon your Personal System keyboard and the code page 
         you are using, you may not have the solid vertical bar to select. 
         For this reason, REXX also recognizes the use of the split 
         vertical bar as a logical OR symbol.  Some keyboards may have 
         both characters.  If so, they are not interchangeable; only the 
         character that is equal to the ASCII value of 124 works as the 
         logical OR.  This type of mismatch can also cause the character 
         on your screen to be different from the character on your 
         keyboard. 
 

 SAY ( 3 = 3 ) | ( 5 = 5 )   /* gives '1'                     */
 SAY ( 3 = 4 ) | ( 5 = 5 )   /* gives '1'                     */
 SAY ( 3 = 3 ) | ( 4 = 5 )   /* gives '1'                     */
 SAY ( 3 = 4 ) | ( 4 = 5 )   /* gives '0'                     */
 
 
 For more examples of using the logical operators, select the Examples 
 pushbutton. Logical Operators - Examples  

Inf-HTML End Run - Successful