IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Is scope terminators are mandatory in a cobol program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pushpalatha

New User


Joined: 11 Apr 2005
Posts: 12

PostPosted: Mon Jul 17, 2006 10:36 am
Reply with quote

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
View user's profile Send private message
Rupa.P.V
Warnings : 1

New User


Joined: 04 Jul 2006
Posts: 30

PostPosted: Mon Jul 17, 2006 12:22 pm
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Jul 17, 2006 12:35 pm
Reply with quote

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
View user's profile Send private message
Hanfur

Active User


Joined: 21 Jun 2006
Posts: 104

PostPosted: Mon Jul 17, 2006 1:19 pm
Reply with quote

This simply esnures improved readbility of code and would be easy in maintaing..

-Han.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jul 18, 2006 3:45 am
Reply with quote

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
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Wed Jul 19, 2006 6:43 pm
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Jul 20, 2006 1:07 am
Reply with quote

As for you TOP-DOWN question, see this Previous Post
If you still have questions, please come back

Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top