View previous topic :: View next topic
|
Author |
Message |
sashi
New User
Joined: 14 Sep 2005 Posts: 54 Location: Chennai
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
What's wrong with trying it out yourself as you have already compiled the program. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
CICS Guy wrote: |
ps. are you GMs just trying to boost your post count? |
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 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
No, I'm trying to encourage independent learning and manual reading. But it goes ever so slowly .... |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
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. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
manikawnth
New User
Joined: 07 Feb 2007 Posts: 61 Location: Mumbai
|
|
|
|
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 ).
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
ElHachu
New User
Joined: 12 Mar 2010 Posts: 9 Location: Madrid
|
|
|
|
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 |
|
|
|