I think what you mean is this:
PERFORM 1050-LOOP THRU 1059-EXIT VARYING JC FROM 1 BY 1 UNTIL JC = 99
END-PERFORM
1050-LOOP.
IF FIRST-NAME NOT = "ROBERT"
GO TO 1059-EXIT
END-IF
IF TYPE NOT = 195
GO TO 1059-EXIT
END-IF
IF NOT SO-ON
GO TO 1059-EXIT
END-IF
IF NOT SO-FORTH
GO TO 1059-EXIT
END-IF
PERFORM 1050-SUCH-AND-SUCH END-PERFORM
1059-EXIT.
EXIT.
In structured programming, it is perfectly acceptable to use GO TO within a
paragraph. It is NOT acceptable to use GO TO outside of a paragraph.
Joe
On Sat, Jun 6, 2020 at 12:42 AM Bob Bridges <[email protected]> wrote:
> I realize this is a bit of a change in subject (and it's not as if we need
> yet another one), but I avoid this construction. My phobia is based on an
> extreme example: In their zeal never to use GOTOs, I've frequently seen
> programmers write paragraphs like this:
>
> PERFORM 1050-LOOP VARYING JC FROM 1 BY 1 TO 99
>
> 1050-LOOP.
> IF X < 1000
> IF FIRST-NAME NOT = "ROBERT"
> IF TYPE = 195
> IF SO-ON
> IF SO-FORTH
> EXECUTE 1050-SUCH-AND-SUCH
> END-IF
> END-IF
> END-IF
> END-IF
> END-IF
>
> Gives me a headache to try to evaluate that. Much better, in my opinion,
> to introduce ONE LOUSY "GOTO EO-PARAGRAPH" like this:
>
> PERFORM 1050-LOOP THRU 1059-LOOP VARYING JC FROM 1 BY 1 TO 99
>
> 1050-LOOP.
> IF X > 999 GOTO 1059-LOOP.
> IF FIRST-NAME = "ROBERT" GOTO 1059-LOOP.
> IF TYPE <> 195 GOTO 1059-LOOP.
> IF NOT SO-ON GOTO 1059-LOOP.
> IF NOT SO-FORTH GOTO 1059-LOOP.
> EXECUTE 1050-SUCH-AND-SUCH
> 1059-LOOP.
>
> Keep in mind I haven't programmed in COBOL since Y2K; I had to look up the
> syntax, I probably got part of it wrong nonetheless, and I'll bet there are
> easier ways to do it nowadays. In REXX, for example, they have the ITERATE
> statement:
>
> do jc=1 to 99
> if x>99 then iterate
> if firstname='ROBERT' then iterate
> if type<>195 then iterate
> if \soon then iterate
> if \soforth then iterate
> call suchandsuch
> end
>
> However you do it, I vastly prefer skip-to-next-item over nested Ifs. But
> I confess that one single nested IF is not going to give me a headache; I
> just react when I see one. Not your fault :).
>
> ---
> Bob Bridges, [email protected], cell 336 382-7313
>
> /* In an emergency, a drawstring from a parka hood can be used to strangle
> a snoring tent mate. -"Camping Tips" */
>
> -----Original Message-----
> From: IBM Mainframe Discussion List [mailto:[email protected]] On
> Behalf Of Gibney, Dave
> Sent: Friday, June 5, 2020 16:17
>
> Using OP
> IF TVOLL (IND1) NOT = HIGH-VALUE
> AND SMOD (IND1) = 'B' OR 'R'
>
> I would do
> IF TVOLL (IND1) NOT = HIGH-VALUE
> IF SMOD (IND1) = 'B' OR 'R'
> Do the stuff
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN