IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

IF statement question


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rpenner

New User


Joined: 26 Apr 2006
Posts: 22
Location: Canada

PostPosted: Fri Jan 09, 2009 10:18 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Jan 09, 2009 10:43 pm
Reply with quote

A negated combined condition requires the combined condition to be enclosed in parentheses.......
Take a look at Combined conditions....
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Jan 09, 2009 10:46 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Jan 09, 2009 10:48 pm
Reply with quote

See Table 27 in the links that CICS Guy and I have pointed to.
Back to top
View user's profile Send private message
rpenner

New User


Joined: 26 Apr 2006
Posts: 22
Location: Canada

PostPosted: Fri Jan 09, 2009 11:14 pm
Reply with quote

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
View user's profile Send private message
rpenner

New User


Joined: 26 Apr 2006
Posts: 22
Location: Canada

PostPosted: Fri Jan 09, 2009 11:16 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Jan 09, 2009 11:30 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
Search our Forums:

Back to Top