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
 

 

COBOL "GO TO"

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

New User


Joined: 30 Sep 2008
Posts: 30
Location: India

PostPosted: Fri Feb 05, 2010 2:09 pm    Post subject: COBOL "GO TO"
Reply with quote

Hi All..I have a small query..


Code:
IF WS-IO-NUM NOT NUMERIC THEN
       MOVE ZERO TO WS-IO-FILE-REQUEST-NUM.

    GO TO 210-IO-READ
          215-IO-READ-GTEQ
          220-IO-READ-UPDATE
          225-IO-READ-UPDATE-GTEQ
          230-IO-WRITE
          240-IO-REWRITE
          250-IO-DELETE
          260-IO-UNLOCK
          270-IO-STARTBR
          280-IO-READNEXT
          290-IO-READPREV
          300-IO-ENDBR
          230-IO-WRITE
          310-IO-READ-SET


I have code like above in one of the progs..Does this mean - if my "IF" condition is satisfied all the mentioned lables are executed one after another?? Thanks.
Back to top
View user's profile Send private message

bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Feb 05, 2010 2:58 pm    Post subject:
Reply with quote

Hi Mohan,

As Per document it should give control to first Paragraph of goto.
Here it would be

Code:
210-IO-READ


http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/evfeb4ls02.htm
Back to top
View user's profile Send private message
mohanrazz

New User


Joined: 30 Sep 2008
Posts: 30
Location: India

PostPosted: Fri Feb 05, 2010 3:07 pm    Post subject: Reply to: COBOL "GO TO"
Reply with quote

Bhairon..thanks..
I too have never seen more than one label in GO TO statement..I am still wondering..if this gives control to only first label why the rest of all are coded..this code is very much in live..i still wonder is there any possiblity that all the labels are executed??
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Feb 05, 2010 3:13 pm    Post subject:
Reply with quote

Is there any depending upon condition below GOTO
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Feb 05, 2010 3:14 pm    Post subject:
Reply with quote

does it say anywhere near the end depending on
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Feb 05, 2010 3:18 pm    Post subject:
Reply with quote

Yes Just have a look on below document

http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/evfeb4ls02.htm
Quote:
Format 2 (Conditional GO TO)

Description
The conditional GO TO statement transfers control to one of a series of procedures, depending on the value of the identifier. The maximum number of procedure-names for a conditional GO TO statement is 255.
Format 2 (Conditional GO TO)

*---------------*
V +
->->---GO-*--*--procedure-name-1*-DEPENDING--*--*-identifier--><-
*TO* *ON*


procedure-name-1
Procedure-name-1 must be a procedure or a section in the same Procedure Division as GO TO.


Identifier
Identifier must be a numeric elementary data item which is an integer.

If 1, control is transferred to the first statement in the procedure named by the first occurrence of procedure-name-1;
If 2, control is transferred to the first statement in the procedure named by the second occurrence of procedure-name-1, and so forth.
If the value of identifier is anything other than a value within the range of 1 through n, (where n is the number of procedure-names specified in this GO TO statement), no control transfer occurs. Instead, control passes to the next statement in the normal sequence in running the
Back to top
View user's profile Send private message
mohanrazz

New User


Joined: 30 Sep 2008
Posts: 30
Location: India

PostPosted: Fri Feb 05, 2010 3:35 pm    Post subject:
Reply with quote

yeah..yes..thanks guys..there is "DEPENDING ON"..i think i missed out that..now it is ok icon_biggrin.gif thx
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Feb 05, 2010 3:55 pm    Post subject:
Reply with quote

Good to hear your doubt got cleared icon_wink.gif

But it is always better to make the effort to find out your queries other then depending on others icon_exclaim.gif
Back to top
View user's profile Send private message
CaptBill

New User


Joined: 28 May 2009
Posts: 20
Location: Oklahoma City, OK USA

PostPosted: Fri Feb 12, 2010 4:32 am    Post subject:
Reply with quote

I would avoid a "Go TO ... DEPENDING" construct and replace it with an EVALUATE construct. It will be much clearer to the person that comes after you and has to do maintenance.

Always write code for maintenance, and you will make everyone's job easier.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Feb 12, 2010 7:01 am    Post subject:
Reply with quote

bhairon singh rathore wrote:
As Per document it should give control to first Paragraph of goto.
Here it would be

Code:
210-IO-READ


http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/evfeb4ls02.htm

Buzz, wrong answer.....
For the COBOL/400 people:
If the value of identifier is anything other than a value within the range of 1 through n, (where n is the number of procedure-names specified in this GO TO statement), no control transfer occurs. Instead, control passes to the next statement in the normal sequence in running the program.
and for the real mainframers:
If the value of identifier is anything other than a value within the range of 1 through n (where n is the number of procedure-names specified in this GO TO statement), no control transfer occurs. Instead, control passes to the next statement in the normal sequence of execution.
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 Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Include/omit with "ALL" pa... mgl DFSORT/ICETOOL 6 Wed Jun 14, 2017 2:31 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm


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