2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,5 +1,14 @@
{{Control Structures}}
In this task, we document common flow-control structures.
One common example of a flow-control structure is the <tt>goto</tt> construct.
Note that [[Conditional Structures]] and [[Iteration|Loop Structures]]
have their own articles/categories.
;Task:
Document common flow-control structures.
One common example of a flow-control structure is the &nbsp; <big><code> goto </code></big> &nbsp; construct.
Note that &nbsp; [[Conditional Structures]] &nbsp; and &nbsp; [[Iteration|Loop Structures]] &nbsp; have their own articles/categories.
;Related tasks:
* &nbsp; [[Conditional Structures]]
* &nbsp; [[Iteration|Loop Structures]]
<br><br>

View file

@ -1,23 +1,38 @@
PROGRAM-ID. Perform-Example.
identification division.
program-id. altering.
PROCEDURE DIVISION.
Main.
PERFORM Moo
PERFORM Display-Stuff
PERFORM Boo THRU Moo
procedure division.
main section.
GOBACK
.
*> And now for some altering.
contrived.
ALTER story TO PROCEED TO beginning
GO TO story
.
Display-Stuff SECTION.
Foo.
DISPLAY "Foo " WITH NO ADVANCING
.
*> Jump to a part of the story
story.
GO.
.
Boo.
DISPLAY "Boo " WITH NO ADVANCING
.
*> the first part
beginning.
ALTER story TO PROCEED to middle
DISPLAY "This is the start of a changing story"
GO TO story
.
Moo.
DISPLAY "Moo"
.
*> the middle bit
middle.
ALTER story TO PROCEED to ending
DISPLAY "The story progresses"
GO TO story
.
*> the climatic finish
ending.
DISPLAY "The story ends, happily ever after"
.
*> fall through to the exit
exit program.

View file

@ -0,0 +1,23 @@
PROGRAM-ID. Perform-Example.
PROCEDURE DIVISION.
Main.
PERFORM Moo
PERFORM Display-Stuff
PERFORM Boo THRU Moo
GOBACK
.
Display-Stuff SECTION.
Foo.
DISPLAY "Foo " WITH NO ADVANCING
.
Boo.
DISPLAY "Boo " WITH NO ADVANCING
.
Moo.
DISPLAY "Moo"
.

View file

@ -0,0 +1,12 @@
...
ASSIGN 1101 to WHENCE !Remember my return point.
GO TO 1000 !Dive into a "subroutine"
1101 CONTINUE !Resume.
...
ASSIGN 1102 to WHENCE !Prepare for another invocation.
GO TO 1000 !Like GOSUB in BASIC.
1102 CONTINUE !Carry on.
...
Common code, far away.
1000 do something !This has all the context available.
GO TO WHENCE !Return whence I came.

View file

@ -0,0 +1,4 @@
ASSIGN 2000 TO WHENCE !Deviant "return" from 1000 to invoke 2000.
ASSIGN 1103 TO THENCE !Desired return from 2000.
GO TO 1000
1103 CONTINUE

View file

@ -0,0 +1,6 @@
SUBROUTINE FRED(X,*,*) !With placeholders for unusual parameters.
...
RETURN !Normal return from FRED.
...
RETURN 2 !Return to the second label.
END

View file

@ -0,0 +1,9 @@
XX:DO WHILE(condition)
statements...
NN:DO I = 1,N
statements...
IF (...) EXIT XX
IF (...) CYCLE NN
statements...
END DO NN
END DO XX