FYI, in COBOL:

SMOD (IND1) = 'B' OR 'R'

Evaluates as:

SMOD (IND1) = 'B' OR SMOD (IND1) = 'R'

The negative test requires AND instead of OR:

SMOD (IND1) NOT = 'B' AND 'R'

Evaluates to:

SMOD (IND1) NOT = 'B' AND SMOD (IND1) NOT = 'R'

Your last example has tripped up more than one novice COBOL coder and is 
obvious (to us) as a tautology, but not to the novices.  I have seen this error 
multiple times in code reviews for less experienced coders.

Peter

-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of 
Paul Gilmartin
Sent: Friday, June 5, 2020 4:33 PM
To: [email protected]
Subject: Re: COBOL Question

EXTERNAL EMAIL

On Fri, 5 Jun 2020 20:17:06 +0000, Gibney, Dave wrote:

>Using OP
>         IF TVOLL (IND1) NOT = HIGH-VALUE
>         AND SMOD (IND1) = 'B' OR 'R'
>
>I would do
>         IF TVOLL (IND1) NOT = HIGH-VALUE
>              IF SMOD (IND1) = 'B' OR 'R'
>                  Do the stuff
> 
I have (almost) never coded COBOL, so I have trouble wrapping my head around:
    SMOD (IND1) = 'B' OR 'R'

Does it mean:
    ( SMOD (IND1) = 'B' ) OR 'R'  or
    SMOD (IND1) = ( 'B' OR 'R' )  or (implied Distributive Law):
    SMOD (IND1) = 'B' OR SMOD (IND1) = 'R'

I'd have even more trouble with:
    SMOD (IND1) NOT = 'B' OR 'R'
    SMOD (IND1) NOT = 'B' OR SMOD (IND1) NOT = 'R'

... which seems to be a verbose expression for TRUE.  I've seen programmers 
fall into that trap.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
[email protected] with the message: INFO IBM-MAIN

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to