Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
IF statement question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: IF statement question
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: 2150
Location: At my coffee table

PostPosted: Fri Jan 09, 2009 10:43 pm    Post subject:
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    Post subject:
Reply with quote

No. See http://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    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

Terry Heinze wrote:
No. See http://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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compute statement with Cobol Z/os 5.2 Chetan Kumar COBOL Programming 2 Fri May 11, 2018 8:02 pm
No new posts JES2 EXIT 6 QUESTION Randy Horowitz All Other Mainframe Topics 30 Tue Feb 06, 2018 5:47 pm
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us