On Fri, 5 Jun 2020 17:31:16 +0000, Seymour J Metz wrote:

>I'm pretty sure that the issue is operator precedence.
>
>(SMOD (IND1) = 'B' OR 'R') means (SMOD (IND1) = 'B' OR SMOD (IND1) = 'R')
> 
Ouch!  That's not operator precedence; that's implied Distributive Law.
Does COBOL work that way?  I hope not.  And what about:
    (SMOD (IND1) = 'B' AND SMOD (IND1) = 'R')
as a verbose way of coding FALSE?

>________________________________________
>From: Bernd Oppolzer
>Sent: Friday, June 5, 2020 1:10 PM
>
>Don't know if this is the right place to ask ...
>
>after 25 years playing with other languages like PL/1, C and ASSEMBLER,
>I have now to work with COBOL again. Took me some time to get started,
>because my COBOL knowledge was at a, say, 1970s level :-)
>
>Now I am in the 4th month of my assignment, and I feel more secure with
>such things like EVALUATE, inline PERFORM, SEARCH etc. etc. (avoiding GO
>TOs
>most of the time).
>
>But today I had a strange experience with the following (not so
>complicated)
>IF condition:
>
>            IF (TVOLL (IND1) NOT = HIGH-VALUE)
>            AND (SMOD (IND1) = 'B' OR 'R')
>
>I first coded it without the parantheses and it did not work ...
>
>            IF TVOLL (IND1) NOT = HIGH-VALUE
>            AND SMOD (IND1) = 'B' OR 'R'
>
>the first part of the condition was false (TVOLL ... was HIGH-VALUE
>indeed),
>and so I hoped that the combined condition would be false, although SMOD
>... was R.
>But: nope.
>
>This must be a misunderstanding at my part, what the abbreviation ... OR
>'R' ...
>means in this case. Maybe in combination with the AND.
>
>Could someone please explain the rules or give any hint? Of course, it
>is always
>a good idea to use parantheses, when in doubt. But I really thought that
>it would
>be ok without parantheses in this case ... what is the problem here, and
>what are
>the semantics in the variant without parantheses?
>
>Thanks, kind regards
>
>Bernd

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to