Re: Help! GO TO and PERFORM THRU!



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. Does it really
matter. 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.

Incidently, am I the last person using SECTIONS. I have heard people
talking about 'falling through' but I don't get this problem. When I
want to exit a section I do just that with the EXIT SECTION statement.

Regards

Razor





.



Relevant Pages

  • Re: Help! GO TO and PERFORM THRU!
    ... the validation fails ... I have personally heard many criticisms of the COBOL GO TO statement ... MOVE 1 TO WS-SUB. ...
    (comp.lang.cobol)
  • Re: Validation
    ... they will have to enter/select a value into a CboCommCode in order to click the Close button to exit out of the form. ... Don't use the On Exit event of the combo box. ... If the validation fails, set Cancel = 1. ...
    (microsoft.public.access.formscoding)