CONTINUE in IF statement.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
User avatar
Rima Bali
Registered Member
Posts: 22
Joined: Wed Apr 18, 2018 8:26 pm

CONTINUE in IF statement.

Post by Rima Bali »

Hi -

Please see the following code:

Code: Select all

IF TB-ABCDE-NORESP AND WS-LTYPE-PART  
   AND TB-ABCDE-ACTIVE                   
   IF (WS-IMSSEG-NORESP                
	  AND OR-CA-CODE    = 'BO')    
	   OR (OEMJCARRI    = 'BO'     
	   OR  OEMCARRI     = 'BO')    
  	      IF TB-FLG AND 
        	 (WS-NO-H-SW = 'Y')         
          	CONTINUE

..
                    
In that below code is new code:

Code: Select all

IF TB-FLG AND 
        	 (WS-NO-H-SW = 'Y')         
          	CONTINUE
rest is existing code. My question is if I don't write CONTINUE, the control will still go to next executable statement. Is that correct? I have tested it but want to confirm if I got it correct.

One more thing I want to ask and that is in the existing code there are nested IF statements, why they have not used CONTINUE? Deos not that make a difference?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: CONTINUE in IF statement.

Post by Robert Sample »

CONTINUE is a no-operation statement. There are a few places where you need it (such as in a paragraph with no other statements), but for the most part it is optional.
User avatar
Rima Bali
Registered Member
Posts: 22
Joined: Wed Apr 18, 2018 8:26 pm

Re: CONTINUE in IF statement.

Post by Rima Bali »

Thanks for the insight. That means both the below codes will behave same?

Code: Select all

IF TB-ABCDE-NORESP AND WS-LTYPE-PART  
   AND TB-ABCDE-ACTIVE                   
   IF (WS-IMSSEG-NORESP                
	  AND OR-CA-CODE    = 'BO')    
	   OR (OEMJCARRI    = 'BO'     
	   OR  OEMCARRI     = 'BO')    
  	      IF TB-FLG AND 
        	 (WS-NO-H-SW = 'Y')         
          	CONTINUE

..

                    
and

Code: Select all

IF TB-ABCDE-NORESP AND WS-LTYPE-PART  
   AND TB-ABCDE-ACTIVE                   
   IF (WS-IMSSEG-NORESP                
	  AND OR-CA-CODE    = 'BO')    
	   OR (OEMJCARRI    = 'BO'     
	   OR  OEMCARRI     = 'BO')    
  	      IF TB-FLG AND 
        	 (WS-NO-H-SW = 'Y')         
          	
..
                    
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: CONTINUE in IF statement.

Post by Robert Sample »

What part of my first answer was unclear?
User avatar
Rima Bali
Registered Member
Posts: 22
Joined: Wed Apr 18, 2018 8:26 pm

Re: CONTINUE in IF statement.

Post by Rima Bali »

Robert Sample wrote: Fri Apr 20, 2018 5:10 pmWhat part of my first answer was unclear?
Sorry if it offended you. Just wanted to confirm!
Keval Mehta
New Member
Posts: 9
Joined: Fri Jul 18, 2014 4:09 pm

Re: CONTINUE in IF statement.

Post by Keval Mehta »

Rima Bali wrote: Wed Apr 18, 2018 8:37 pmOne more thing I want to ask and that is in the existing code there are nested IF statements, why they have not used CONTINUE? Deos not that make a difference?
Both the IFs will work same.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: CONTINUE in IF statement.

Post by Robert Sample »

If you want to confirm your answer, why not search the Language Reference manual for what you want? Asking repeatedly the same question is asinine -- the first answer will not change if you ask seven times. And asking multiple times is implying that you don't trust the person's answer; unless you have some reason for that lack of trust, you should believe the answers you are given.
User avatar
Rima Bali
Registered Member
Posts: 22
Joined: Wed Apr 18, 2018 8:26 pm

Re: CONTINUE in IF statement.

Post by Rima Bali »

Thanks Robert. Your answer helped.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”