Re: Code problems with Perform Thru Exit causes fall through



In article <jKSdndgp06PBeTLbnZ2dnUVZ_qWtnZ2d@xxxxxxxxxxx>,
LX-i <lxi0007@xxxxxxxxxxxx> wrote:

[snip]

Who is the arbiter of "good" COBOL, or whether a coding style is a
"problem" or not?

The person who signs the checks for the project, of course. In my
experience this person is usually satisfied if:

1) All paragraphs are performed THRU a matching -EXIT with no intervening
paragraph names between PARA-NAME and PARA-NAME-EXIT.

2) GO TO is allowed to refer only to the -EXIT paragraph immediately
following, the PARA-NAME immediately preceding or the -ABEND routine for
the program... in some instances LEAVE-THIS-PROGRAM (in subroutines) may
be substituted for -ABEND.

If someone's code does what it is supposed to do, and
they document it well, I really don't see the problem.

If the person who signs the check for a project is not smiling then there
is a problem.

[snip]

100-PROCESS-EQPP.
FETCH NEXT EQPP-158 WITHIN UNIT-TO-ACFT SET.

IF ERROR-NUM = "0013"
GO TO 100-PROCESS-EQPP-EXIT
ELSE
IF ERROR-NUM NOT = ZEROES
GO TO ERROR-HANDLER.

PERFORM PROCESS-THIS-EQUIP.

GO TO 100-PROCESS-EQPP.

100-PROCESS-EQPP-EXIT.
EXIT.

Now, I don't particularly care for this style - but is it bad COBOL?

If ERROR-HANDLER is the -ABEND or the LEAVE-THIS-PROGRAM paragraph then it
violates neither 1) nor 2) given above, therefore it would, in my
experience, make most signers-of-checks smile.

[snip]

It could be written
differently...

100-PROCESS-EQPP.
FETCH FIRST EQPP-158 WITHIN UNIT-TO-ACFT SET.

PERFORM PROCESS-THIS-EQUIP
UNTIL ERROR-NUM > ZEROES.

IF ERROR-NUM NOT = "0013"
GO TO ERROR-HANDLER.

This is certainly smaller, and looks more like the COBOL 85 version, but
I don't like it.

There is no -EXIT paragraph shown; this violates 1) above. If
ERROR-HANDLER is not (see above) then this violates 2). Other folks might
not smile, as well.

[snip]

100-PROCESS-EQUIP.
FETCH FIRST EQPP-158 WITHIN UNIT-TO-EQPP SET.
110-CONTINUE.
IF ERROR-NUM NOT = ZEROES
GO TO 199-X.
PERFORM PROCESS-THIS-EQUIP.
FETCH NEXT EQPP-158 WITHIN UNIT-TO-EQPP SET.
GO TO 110-CONTINUE.
199-X.
EXIT.

Neither paragraph can be performed through its matching -EXIT, violating
1). GO TO range is outside of an immediately preceding paragraph or the
matching -EXIT. Someone who signs checks will, most likely, not be
smiling.

DD

.



Relevant Pages