View previous topic :: View next topic
|
Author |
Message |
rpenner
New User
Joined: 26 Apr 2006 Posts: 22 Location: Canada
|
|
|
|
Consider the following IF statement:
IF NOT ERROR-FOUND OR NEW-RECORD
PERFORM xxx-PARAGRAPH.
where ERROR-FOUND and NEW-RECORD are 88 levels in working storage.
Does the 'NOT' apply to the second operand (NEW-RECORD)?
In other words, if ERROR-FOUND and NEW-RECORD are both false, will xxx-PARAGRAPH be executed? Note that this in COBOL74.
Thanks. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
A negated combined condition requires the combined condition to be enclosed in parentheses.......
Take a look at Combined conditions.... |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
See Table 27 in the links that CICS Guy and I have pointed to. |
|
Back to top |
|
|
rpenner
New User
Joined: 26 Apr 2006 Posts: 22 Location: Canada
|
|
|
|
CICS Guy wrote: |
A negated combined condition requires the combined condition to be enclosed in parentheses.......
Take a look at Combined conditions.... |
Thanks. |
|
Back to top |
|
|
rpenner
New User
Joined: 26 Apr 2006 Posts: 22 Location: Canada
|
|
|
|
Terry Heinze wrote: |
No. See publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR30/6.1.6.13?SHELF=&DT=20050714120224
Combined conditions, especially ones involving negation, can be very easily coded/interpreted incorrectly. If I understand your intent correctly, I'd code this as
Code: |
EVALUATE TRUE
WHEN ERROR-FOUND
WHEN NEW-RECORD
CONTINUE
WHEN OTHER
PERFORM xxx-PARAGRAPH
END-EVALUATE |
The reason I would use EVALUATE instead of IF is for flexibility for future condition checking. |
Thanks...unfortunately can't use EVALUATE in COBOL74. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Ah, I forgot that you'd mentioned that initially. In that case I'd
Code: |
IF ERROR-FOUND
OR NEW-RECORD
CONTINUE
ELSE
PERFORM xxx-PARAGRAPH
END-IF |
|
|
Back to top |
|
|
|