Thanks to all who responded ... this helped a lot. And this is definitely the right place to ask :-)
Have a nice day. Kind regards Bernd Am 05.06.2020 um 19:59 schrieb Farley, Peter x23353:
In COBOL the AND logical operator has precedence over the OR logical operator, so without parenthesis your example is evaluated by the compiler as: IF (TVOLL (IND1) NOT = HIGH-VALUE AND SMOD (IND1) = 'B') OR SMOD (IND1) = 'R' You said that SMOD (IND1) = 'R' so the condition evaluate as TRUE. Logical operators AND and OR are parsed in the same way as arithmetic operators '*' (multiply) and '+' (add). Without parentheses the higher-precedence operations are combined first. HTH Peter -----Original Message----- From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of Bernd Oppolzer Sent: Friday, June 5, 2020 1:11 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: COBOL Question EXTERNAL EMAIL 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 -- 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 lists...@listserv.ua.edu with the message: INFO IBM-MAIN
-- Oppolzer-Informatik Dipl. Inf. Bernd Oppolzer Bärenhofstraße 23 70771 Leinfelden-Echterdingen ————————————————————— Tel.: +49 711 7949591 priv.: +49 711 7949590 mobil: +49 151 75005359 eMail: bernd.oppol...@t-online.de <mailto:bernd.oppol...@t-online.de> Web: http://bernd-oppolzer.de/job.htm ————————————————————— Für Umsatzsteuerzwecke: SteuerNr.: 97 076 / 29921 USt-ID-Nr.: DE 147 700 393 ————————————————————— Oppolzer-Informatik 1983 - 2019 36years of experience in computer science** ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN