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
 

 

Is END-IF is mandetory in IF statment?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sashi

New User


Joined: 14 Sep 2005
Posts: 54
Location: Chennai

PostPosted: Tue Mar 09, 2010 8:35 pm    Post subject: Is END-IF is mandetory in IF statment?
Reply with quote

Hi All,
Is END-IF is mandetory in IF statment?
I did try to compile the program with out END-IF, its compiled successfully.
Just I want to know how it will be execute it?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 09, 2010 8:36 pm    Post subject:
Reply with quote

What's wrong with trying it out yourself as you have already compiled the program.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Tue Mar 09, 2010 9:08 pm    Post subject:
Reply with quote

There is a link to manuals at the top of this page. If you click on it, find the COBOL Language Reference manual, and read you can find out everything you want to know about the IF statement.
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: Tue Mar 09, 2010 9:28 pm    Post subject: Re: Is END-IF is mandetory in IF statment?
Reply with quote

sashi wrote:
Is END-IF is mandetory in IF statment?
No....
Quote:
Just I want to know how it will be execute it?
It depends on where the period is....

Delimited scope statements
In general, a DELIMITED SCOPE statement uses an explicit scope terminator to turn a conditional statement into an imperative statement. The resulting imperative statement can then be nested. Explicit scope terminators can also be used to terminate the scope of an imperative statement. Explicit scope terminators are provided for all COBOL statements that can have conditional phrases.
Unless explicitly specified otherwise, a delimited scope statement can be specified wherever an imperative statement is allowed by the rules of the language.


The scope of an IF statement can be terminated by any of the following:
An END-IF phrase at the same level of nesting
A separator period
If nested, by an ELSE phrase associated with an IF statement at a higher level of nesting


ps. are you GMs just trying to boost your post count? icon_rolleyes.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 09, 2010 9:37 pm    Post subject:
Reply with quote

CICS Guy wrote:
ps. are you GMs just trying to boost your post count? icon_rolleyes.gif
Nah, just trying to invoke a sense of adventure in the OP by trying to get him/her to actually try something before posting.

Sado necrophillia equine if you ask me icon_rolleyes.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Tue Mar 09, 2010 9:38 pm    Post subject:
Reply with quote

No, I'm trying to encourage independent learning and manual reading. But it goes ever so slowly ....
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: Tue Mar 09, 2010 9:48 pm    Post subject:
Reply with quote

expat wrote:
just trying to invoke a sense of adventure in the OP by trying to get him/her to actually try something before posting.
Robert Sample wrote:
No, I'm trying to encourage independent learning and manual reading. But it goes ever so slowly ....
I've personally (speaking for myself) noticed that a helping hand (or in this case a url) aids in the learning process....

BTW,
expat wrote:
Sado necrophillia equine if you ask me :roll
Sado(?) a dead horse?....I did flunk Latin more times than I passed it...grin....
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Wed Mar 10, 2010 10:24 am    Post subject:
Reply with quote

Robert Sample wrote:
No, I'm trying to encourage independent learning and manual reading. But it goes ever so slowly ....
My own attempts at behavior modification have had very little success. icon_sad.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 10, 2010 10:36 am    Post subject: Reply to: Is END-IF is mandetory in IF statment?
Reply with quote

I believe we have had more success than is shown. . .

Just look at how many people view these discussions. . .

Many take away info that is never recorded within our forum.

The more we show the way to an answer (rather than only an answer) the more we influence those who will learn.

imho,

d
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Mar 10, 2010 2:45 pm    Post subject: Re: Is END-IF is mandetory in IF statment?
Reply with quote

sashi wrote:
Is END-IF is mandetory in IF statment?
I did try to compile the program with out END-IF, its compiled successfully.
Just I want to know how it will be execute it?
It's not only with "IF statement", actually, in this context, IF should not raise your eye-brows, instead "end scope terminator (".")" can be of your interest, as CICS Guy has said. (...most probably you have used the period, please show us your actual code to be sure)
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Wed Mar 10, 2010 2:58 pm    Post subject: @Sashi
Reply with quote

YOu got no compiler errors.
It means you have to be more careful where u placed the period.
You might have placed the period 5 to 10 statements down the line where u actually want to end and still the compiler assumes it as scope terminator (As it cant read ur mind icon_smile.gif ).
Make it a habit of placing an end-if as scope terminator (instead of period) for readability and maintainability unless you are very sure that nobody else will touch your code in future.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Fri Mar 19, 2010 9:01 pm    Post subject:
Reply with quote

I know most people know this, but I just want to mention the behavior of NEXT SENTENCE : It goes to the next period !

You can't just replace periods with scope terminators if you leave next sentence.

Use of 'NEXT SENTENCE' is not allowed here.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Sat Mar 20, 2010 12:00 am    Post subject:
Reply with quote

As GuyC points out, not knowing how NEXT SENTENCE works can get you in big trouble. I much prefer using CONTINUE and scope terminators.
Back to top
View user's profile Send private message
ElHachu

New User


Joined: 12 Mar 2010
Posts: 9
Location: Madrid

PostPosted: Sat Mar 20, 2010 5:36 pm    Post subject:
Reply with quote

I agree with Anuj Dhawan, The sentences that will be executed would be all before the period:

IF [conditions]

[sentences]

.

Or

IF [conditions]

[sentences]

ELSE

[more sentences]

.

And as Terry says, be careful with NEXT SENTENCE. Many companys do not allow using it.
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 How to use Read/Find statment.... purushottam Java & MQSeries 4 Mon Mar 02, 2009 8:37 pm
No new posts S0C7 ABEND when no arithmatic statment Terry Heinze ABENDS & Debugging 26 Sun Dec 07, 2008 12:30 am
No new posts SYNTAX ERROR in OUTFIL statment in my... Arun Raj JCL & VSAM 11 Wed Nov 26, 2008 3:00 pm
No new posts Insead of STRING STATMENT vicky10001 COBOL Programming 7 Mon Aug 04, 2008 5:46 pm
No new posts cobol statment starting with ON Dhanya Praju COBOL Programming 6 Fri Jul 25, 2008 1:35 pm


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