Re: Help! GO TO and PERFORM THRU!
- From: "Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx>
- Date: Wed, 28 Feb 2007 11:56:33 -0700
Michael Mattias<mmattias@xxxxxxxxxxxxxx> 02/28/07 10:53 AM >>>
"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
Here's something similar in C (and other C-like languages, I assume):
if (condition1)
{
if (condition2)
DoSomething2();
DoSomething1();
}
I personally don't find that hard to read, though I do understand your
point.
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).
Wow, now that one is, umm, interesting. :-)
I tell others to use block IF or single-line IF - whatever they are comfy
with - but don't intersperse them like this.
COBOL doesn't really have a 'single line IF' in the same sense as the other
examples. By that I mean you can't have:
if condition1
if condition2 perform DoSomething2
perform DoSomething1
end-if.
(Well, you can have it, but it won't do what you intend! :-)
Anyway....
---
Frank Swarbrick
Senior Developer/Analyst - Mainframe Applications
FirstBank Data Corporation - Lakewood, CO USA
.
- Follow-Ups:
- 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
- Re: Help! GO TO and PERFORM THRU!
- From: Pete Dashwood
- Re: Help! GO TO and PERFORM THRU!
- From: Michael Mattias
- Help! GO TO and PERFORM THRU!
- Prev by Date: Re: Help! GO TO and PERFORM THRU!
- Next by Date: Re: Help! GO TO and PERFORM THRU!
- Previous by thread: Re: Help! GO TO and PERFORM THRU!
- Next by thread: Re: Help! GO TO and PERFORM THRU!
- Index(es):
Relevant Pages
|