Hi Bernd,
My COBOL is about as old as yours is, but I have a niggling in the back of my
mind that AND takes precedence over OR, and if so, your equation became
IF ( TVOLL (IND1) NOT = HIGH-VALUE AND SMOD (IND1) = 'B' ) OR
SMOD (IND1) = 'R' so the TVOL and B would become false, but the stand-alone R
would evaluate to true, thus making it true.
I just verified that with one of my senior COBOL developers and he concurred
that the AND does take precedence.
Rex
-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of
Bernd Oppolzer
Sent: Friday, June 5, 2020 12:11 PM
To: [email protected]
Subject: [External] COBOL Question
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
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to
[email protected] with the message: INFO IBM-MAIN
The information contained in this message is confidential, protected from
disclosure and may be legally privileged. If the reader of this message is not
the intended recipient or an employee or agent responsible for delivering this
message to the intended recipient, you are hereby notified that any disclosure,
distribution, copying, or any action taken or action omitted in reliance on it,
is strictly prohibited and may be unlawful. If you have received this
communication in error, please notify us immediately by replying to this
message and destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN