Many moons ago when I wrote COBOL for a living I used the hell out of 88 Levels.
Its makes for really pretty code but it is hell to debug sometimes like compound Condition. 1 or 2 items it an 88 is easy, 40 or 50 is not, same with compound conditions -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Gibney, Dave Sent: Friday, June 5, 2020 2:56 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: COBOL Question Also, it's often better to nest than to make compound conditions. > -----Original Message----- > From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On > Behalf Of Charles Mills > Sent: Friday, June 05, 2020 12:54 PM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: COBOL Question > > I long ago decided never to bother looking up or thinking about operator > precedence. If I am not immediately certain straight out of the box then I use > parentheses. > > Charles > > > -----Original Message----- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] > On Behalf Of Bernd Oppolzer > Sent: Friday, June 5, 2020 12:23 PM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: COBOL Question > > I hope you don't mind if I comment once again; > > my original coding was: > > IF TVOLL (IND1) NOT = HIGH-VALUE > AND SMOD (IND1) = 'B' OR 'R' > > and as I learned now from your helpful posts, this is expanded to > > IF TVOLL (IND1) NOT = HIGH-VALUE > AND SMOD (IND1) = 'B' OR SMOD (IND1) = 'R' > > (which would have alarmed me, if I had seen it in this variant, BTW) and then, > because of operator precedence, evaluated as > > IF (TVOLL (IND1) NOT = HIGH-VALUE > AND SMOD (IND1) = 'B') > OR SMOD (IND1) = 'R' > > so that in my case (SMOD ... being 'R') the condition evaluated to true, which > was not what I had expected. > > This is a little bit counter intuitive IMHO, because the abbreviation 'B' OR > 'R' > suggests that the list of values both rely to the right condition (only) and > so I > thought the evaluation would be > > IF TVOLL (IND1) NOT = HIGH-VALUE > AND (SMOD (IND1) = 'B' OR 'R') > > I expected somehow an implicit paranthese because of the abbreviation ... > > What I would take as a conclusion (for me) from this experience: > it is best to use parantheses, especially if there is a combination of AND and > OR ... and when using abbreviations. > > Thanks again, kind regards > have a nice weekend > > Bernd > > > > Am 05.06.2020 um 20:48 schrieb Bob Bridges: > > Seems to me that ~is~ operator precedence: We evaluate AND before OR, > just as we evaluate * before +. But that's closely related to the > distributive > rule, right? > > > > P and Q or R > > R or P and Q > > > > ...both evaluate the same way, to "(P and Q) or R". The distributive > > property says that > > > > P and (Q or R) > > > > ...evaluates to > > > > (P and Q) or (P and R) > > > > I'm just as rusty in COBOL as Mr Oppolzer, so I didn't know you could > > say > > > > IF VAR = 'B' OR 'R' > > > > But if you can, it must mean "IF VAR = 'B' OR VAR = 'R'". > > > > --- > > Bob Bridges, robhbrid...@gmail.com, cell 336 382-7313 > > > > /* No one would talk much in society if he knew how often he > > misunderstands others. -Goethe */ > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, send email to > lists...@listserv.ua.edu with the message: INFO IBM-MAIN > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, send email to > lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN