Re: Help! GO TO and PERFORM THRU!
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Feb 2007 15:46:07 +1300
"ruddy" <iruddock@xxxxxxxxxxxxxxxx> wrote in message
news:1172482649.993940.291000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 25, 11:28 pm, r...@xxxxxxxx wrote:
I have used COBOL for many years, even now sometimes, and I must say I
like
it a lot.
I normally use the PERFORM THRU, especially when doing validations. Then,
if
the validation fails
you use a GO TO to get to the, say, 1200-VALIDATION-EXIT procedure, which
has an EXIT statement.
There is nothing wrong with it, I'd say.
Raul Ward
I don't think its worth getting too bogged down worrying about using
GO TO's or not, or PERFORM THRU's. What is more relevant is what do
the existing programs do? If they are already written in a particular
style then you would be well advised to adopt that, at least until you
are 100% comfortable with it.
I have personally heard many criticisms of the COBOL GO TO statement
over the past 20 years and I think people forget about the history.
Some of the code was written before we had the constructs that we have
now and the only way to split some conditions up was to use some GO
TO's. But again, if they already exist don't touch them, unless you
are being tasked to do exactly that. I like to use the GO TO command
as long as I'm not going far :-). For example.
MOVE 1 TO WS-SUB.
B100-ADD.
ADD 1 TO WS-SUB.
IF WS-SUB < 100
IF WS-STATUS-ERROR-FLAG(WS-SUB) = 1
PERFORM PROCESS-ERROR
END-IF
GO TO B100-ADD.
Yes, I know, I know. There is at least one easier method just using a
PERFORM VARYING and you don't have to use a GO TO. But please don't
post it. You would be missing the point I'm making.
I think your point fails to be "made"... :-)
The first status flag in the above will never be tested, the mixing of
scope-delimited COBOL with full-stop-terminated COBOL is ugly and confusing,
and all of this without even looking at whether GO TO is OK or not... :-)
Does it really
matter.
It does if someone else has to maintain it. If you are the only person who
will ever use or change it, then it doesn't. (Have you met Tony Dilworth...
?)
As long as its clear and you can see the place its going to as
in this example I feel its as good as anything.
Well, that's all right then... :-)
(Seriously, there is nothing wrong with GO TO when used carefully and when
the destination is local;;; Richard already commented that the problem is in
the labels and I think he has a point. Having said all of that, I prefer NOT
to use GO TO for my own programs (I'm just not Evangelical about it... :-)))
Incidently, am I the last person using SECTIONS.
No, you're not. I still use them (have since early 70s, after experimenting
with PERFORM...THROUGH) and find them very useful, even in OO COBOL. Have a
look at some code I posted here a few weeks back (something I hardly ever do
because the style wars generated are just tedious...) and feel free to
criticize ... give you a chance to get your own back for my comments
above... :-)
http://groups.google.com/group/comp.lang.cobol/tree/browse_frm/thread/a5bc256300719882/591df69b54314bc6?rnum=21&hl=en&q=productivity&_done=%2Fgroup%2Fcomp.lang.cobol%2Fbrowse_frm%2Fthread%2Fa5bc256300719882%2F8f64437938861860%3Flnk%3Dgst%26q%3Dproductivity%26rnum%3D25%26hl%3Den%26#doc_e59987cf1370a3fa
Pete.
.
- Follow-Ups:
- Re: Help! GO TO and PERFORM THRU!
- From: Michael Mattias
- Re: Help! GO TO and PERFORM THRU!
- From: Howard Brazee
- Re: Help! GO TO and PERFORM THRU!
- From: Michael Mattias
- Re: Help! GO TO and PERFORM THRU!
- References:
- Help! GO TO and PERFORM THRU!
- From: Impy
- Re: Help! GO TO and PERFORM THRU!
- From: raul
- Re: Help! GO TO and PERFORM THRU!
- From: ruddy
- Help! GO TO and PERFORM THRU!
- Prev by Date: Re: Reset data
- Next by Date: Re: Reset data
- Previous by thread: Re: Help! GO TO and PERFORM THRU!
- Next by thread: Re: Help! GO TO and PERFORM THRU!
- Index(es):
Relevant Pages
|