View previous topic :: View next topic
|
Author |
Message |
pushpalatha
New User
Joined: 11 Apr 2005 Posts: 12
|
|
|
|
is explicit scope terminators are mandatory in a cobol program ?
if not , then why we specify them in the cobol programs ?
i tried them without specifying END-EVALUATE,END-PERFORM.it was worked fine. my question is why we specify them without any need.
and one more question is what is meant by top-down approach.
can any one give a brief explanation on that |
|
Back to top |
|
|
Rupa.P.V Warnings : 1 New User
Joined: 04 Jul 2006 Posts: 30
|
|
|
|
Its not mandatory...but depending on the requirement u may have to use the scope terminators....
For example if u have many conditions and u want to end the innermost if condition alone then if u give Period all the if conditios will be ended there itself..
Eg:;
IF (FILE-NSPNLIST-END NOT = 'Y')
PERFORM 4100-SEARCH-CWIPCRLT THRU 4100-EXIT
IF (WS-CWIPCRLT-FOUND = 'Y')
PERFORM 4200-SEARCH-FSSCOMM THRU 4200-EXIT
IF (WS-FSSCOMM-FOUND = 'Y')
PERFORM 4300-CALC-NETQTY THRU 4300-EXIT
END-IF
END-IF
END-IF . . . . . . . . . . . . . . . .
Here if u put period after PERFORM 4300-CALC-NETQTY THRU 4300-EXIT all the if conditions will ended there itself.
Here if u want to close all the if conditions u can just use period.
But if u have any else statements for any of the IF conditions above in that case
scope terminators will useful....
Hope i am clear to u.... |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
pushpalatha wrote: |
i tried them without specifying END-EVALUATE,END-PERFORM.it was worked fine. |
END-EVALUATE,END-PERFORM, END-SEARCH, END-IF are ment for better readability. They don't indicate any specific instruction.
Scope Terminators are not mandetory. When the compilor encounters certain COBOL KEYWORDS like IF, MOVE, PERFORM.........., it automatically terminates the scope of the present statement.
~Vamsi |
|
Back to top |
|
|
Hanfur
Active User
Joined: 21 Jun 2006 Posts: 104
|
|
|
|
This simply esnures improved readbility of code and would be easy in maintaing..
-Han. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
There is more to scope terminators that just readability. Although it does greatly help with that, and it is a requirement in all the coding I review.
Take an example
Code: |
IF VARIABLE-A = CONDITION-A
THEN
IF VARIABLE-B = CONDITION-B
THEN
MOVE CONSTANT-C TO VARIABLE-A
END-IF
ADD 1 TO VARIABLE-A
MOVE VARIABLE-A TO VARIABLE-D
ELSE
MOVE CONSTANT-D TO VARIABLE-D
END-IF.
|
This is a very simple example, but without the scope terminators, you cannot build an IF statement like this.
Dave |
|
Back to top |
|
|
calspach
New User
Joined: 05 May 2006 Posts: 32 Location: USA
|
|
|
|
Exactly. You might be able to get away with just coding .'s when you need to terminate most of the time, but the good old end-if, end-read, end-perform can really come in handy sometimes too. And, I would like to note that the readability issue should be reason enough, even if you can prove to me that you can do it without an end-if, it would certainly be easier to read with it. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
As for you TOP-DOWN question, see this Previous Post
If you still have questions, please come back
Dave |
|
Back to top |
|
|
|