Anonymous user
Flow-control structures: Difference between revisions
Started COBOL example. Added section about GO TO.
(Started COBOL example. Added section about GO TO.) |
|||
Line 289:
}
}</lang>
=={{header|COBOL}}==
=== GO TO ===
Basic use of a GO TO:
<lang cobol> PROGRAM-ID. Flow-Control.
PROCEDURE DIVISION.
Foo.
DISPLAY "Just a reminder: GO TOs are evil."
GO TO Foo
.</lang>
A GO TO can take a DEPENDING ON clause which will cause program flow to go to a certain paragraph/section depending on a certain value.
<lang cobol> GO TO First-Thing Second-Thing Third-Thing
DEPENDING ON Thing-To-Do
* *> Handle invalid thing...</lang>
The previous example is equivalent to:
<lang cobol> EVALUATE Thing-To-Do
WHEN 1
* *> Do first thing...
WHEN 2
* *> Do second thing...
WHEN 3
* *> Do third thing...
WHEN OTHER
* *> Handle invalid thing...
END-EVALUATE</lang>
=={{header|D}}==
|