Re: Help! GO TO and PERFORM THRU!



"Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:54k8niF20o965U1@xxxxxxxxxxxxxxxxxxxxx
the mixing of scope-delimited COBOL with full-stop-terminated COBOL is
ugly and confusing..

Amen.

I find the same thing in BASIC.

These mean the same thing...
IF Condition1 THEN
DoSomething1
END IF
(called 'block if')

and
IF Condition1 THEN DoSomething1
(called "single-line if")


But you can mix and match and boy, that IS confusing...

IF Condition1 THEN
IF Condition2 THEN DoSomething2 <<< Executed only when both
Condition1 and Condition2 are true
DoSomething1 <<< Executed whenever
condition1 is true regardless of condition2
END IF

Of course in Real Life the distance between "IF Condition1" and its
companion END IF is many many lines of source code. Darned near impossible
to figure out what the logic flow is in that case.

It gets worse when (sadly) the single-line IF includes an EXIT or GOTO
statement, eg

IF Condition1 THEN
IF Condition2 THEN DoSomething2: EXIT
DoSomething1
END IF

BASIC EXIT is similar to COBOL EXIT "structure type" (e.g. PARAGRAPH,
PERFORM, SECTION) except 'structure type' is optional; when "structure
type" is omitted EXIT exits the current loop structure regardless of its
type (FOR, DO, IF, TRY, FUNCTION, SUB, SELECT or WHILE).

I tell others to use block IF or single-line IF - whatever they are comfy
with - but don't intersperse them like this.

MCM










.



Relevant Pages

  • Re: return command
    ... I disagree and use Exit a lot because the code is *easier* to maintain. ... function IsValid: boolean; ... if condition1 then begin ...
    (borland.public.delphi.non-technical)
  • Re: return command
    ... Condition1 and condition2 are boolean in the tiny example but not in real ... mb_IconWarning) mrYes) ...
    (borland.public.delphi.non-technical)
  • Re: return command
    ... if not condition1 then ... Exits should only be used on simple, preferably single branch execution and maybe simple loops, but that doesn't mean they are evil. ... Anytime the code gets more complicated the flow should be carefully thought out and not have hastily added Aborts and Exits... ...
    (borland.public.delphi.non-technical)
  • Re: Help! GO TO and PERFORM THRU!
    ... IF Condition1 THEN DoSomething1 ... It gets worse when the single-line IF includes an EXIT or GOTO ... at the cost of typing a couple of braces. ...
    (comp.lang.cobol)
  • Re: Help! GO TO and PERFORM THRU!
    ... IF Condition1 THEN DoSomething1 ... It gets worse when the single-line IF includes an EXIT or GOTO ... SECTION) except 'structure type' is optional; ...
    (comp.lang.cobol)