As our e-mails crossed in the ether, you are absolutely correct in your 
evaluation below.

Rex

-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of 
Bernd Oppolzer
Sent: Friday, June 5, 2020 12:59 PM
To: [email protected]
Subject: [External] Re: COBOL Question

             IF (TVOLL (IND1) NOT = HIGH-VALUE)
             AND (SMOD (IND1) = 'B' OR SMOD (IND1) = 'R')

is OK for me.  That works the same way as the abbreviation.

The problem must be that

             IF TVOLL (IND1) NOT = HIGH-VALUE
             AND SMOD (IND1) = 'B' OR 'R'

evaluates to something like

             IF (TVOLL (IND1) NOT = HIGH-VALUE AND SMOD (IND1) = 'B')
             OR (TVOLL (IND1) ... = 'R') ... ???

This gave me the wrong behaviour and the headaches ...

Thanks, kind regards

Bernd



Am 05.06.2020 um 19:31 schrieb Seymour J Metz:
> I'm pretty sure that the issue is operator precedence.
>
> (SMOD (IND1) = 'B' OR 'R') means (SMOD (IND1) = 'B' OR SMOD (IND1) = 
> 'R')
>
>
> --
> Shmuel (Seymour J.) Metz
> http://mason.gmu.edu/~smetz3
>
> ________________________________________
> From: IBM Mainframe Discussion List [[email protected]] on 
> behalf of Bernd Oppolzer [[email protected]]
> Sent: Friday, June 5, 2020 1:10 PM
> To: [email protected]
> Subject: 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
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions, send 
> email to [email protected] 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: [email protected] <mailto:[email protected]>
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 
[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

Reply via email to