View previous topic :: View next topic |
Author |
Message |
cobcurious Beginner

Joined: 04 Oct 2003 Posts: 68 Topics: 25
|
Posted: Thu Sep 16, 2010 8:08 am Post subject: Syntax for LABEL for GO TO |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Thu Sep 16, 2010 8:19 am Post subject: |
|
|
to which application programming language are you referring? _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
cobcurious Beginner

Joined: 04 Oct 2003 Posts: 68 Topics: 25
|
Posted: Thu Sep 16, 2010 8:26 am Post subject: |
|
|
Hi,
Sorry for not mentioning it. I am trying it in COBOL Z/OS. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Sep 16, 2010 10:16 am Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Thu Sep 16, 2010 10:49 am Post subject: |
|
|
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 |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Thu Sep 16, 2010 1:38 pm Post subject: |
|
|
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 |
|
 |
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Fri Sep 17, 2010 3:12 am Post subject: GO TO |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Sep 17, 2010 5:17 am Post subject: |
|
|
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 |
|
 |
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Fri Sep 17, 2010 8:15 am Post subject: |
|
|
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 |
|
 |
|
|