Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us