MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syntax for LABEL for GO TO

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
cobcurious
Beginner


Joined: 04 Oct 2003
Posts: 68
Topics: 25

PostPosted: Thu Sep 16, 2010 8:08 am    Post subject: Syntax for LABEL for GO TO Reply with quote

Hi,

I have nested multiple IF..END-IF.
Code:
 
              IF
                 IF
                    IF something
                       GO TO LABEL:
                    END-IF
                 END-IF
            LABEL:  DO SOMETHING         
         
     END-IF
                   
     


I want to use GO TO statement to jump to a point within the same paragraph. Can you please let me know what is the syntax of using the labels for the GO TO statement?

Thanks
Cobcurious
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Sep 16, 2010 8:19 am    Post subject: Reply with quote

to which application programming language are you referring?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
cobcurious
Beginner


Joined: 04 Oct 2003
Posts: 68
Topics: 25

PostPosted: Thu Sep 16, 2010 8:26 am    Post subject: Reply with quote

Hi,

Sorry for not mentioning it. I am trying it in COBOL Z/OS.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Sep 16, 2010 10:16 am    Post subject: Reply with quote

cobcurious,

Why do you want to use a GO TO? personally I don't prefer using a GO TO unless it is a must.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Sep 16, 2010 10:49 am    Post subject: Reply with quote

COBOL doesn't have labels.

instead of giving you the answer,
suggest you do a little reading about COBOL program structure.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Thu Sep 16, 2010 1:38 pm    Post subject: Reply with quote

COBOL supports GO TO xxxxx. Many organizations restrict the use of GO TO.

The way you have chosen to code is invalid.
_________________
All the best,

di
Back to top
View user's profile Send private message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Fri Sep 17, 2010 3:12 am    Post subject: GO TO Reply with quote

The only time I ever use GO TO is to jump to the END of a section.

IMO, generally speaking, if you want to jump to a lable in the middle of a section, then this simply means that given certain circumstances, you want to do some special processing. Something like ....(?)
Code:

if x = 4
  go to label-in-middle-of-section
else
   do process1
   do process2
   etc etc
end-if
label-in-middle-of-section:


Personally, I would rewrite this as
Code:

if x NOT = 4
  perform new-section that does process1, process2 etc etc
end-if


Voila - no more need for a GO TO.

Again, I would be tempted to say that you can (re)write any code using the second option.
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Sep 17, 2010 5:17 am    Post subject: Reply with quote

Thru your misuse of the word label in COBOL context you still have not provided the TS an answer to his question.

Label in COBOL has a distinct meaning, and has nothing to do with transfer of control.

cobcurious,
the answer to your question is here
though the link is to an old version of COBOL (30 years), the usage and syntax of GO TO has not changed.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Fri Sep 17, 2010 8:15 am    Post subject: Reply with quote

Cobcurious - Please tell us, What is that you want to do? Why do you think "GO TO some label" is the only solution to your probelm? If you explain the work you got in hands again, may be, someone be able to suggest some alternate way of doing it.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group