Interprogram Communication
12.3 Transferring Flow of Control
Example 12–4 (Cont.) Execution Sequence of Nested CALL Statements
BEGIN.
DISPLAY " 1. MAINPROG has control first.
".
DISPLAY " 2. MAINPROG transfers control to SUB1
".
DISPLAY "
upon executing the following CALL.
".
CALL "SUB1"
DISPLAY "11. MAINPROG has control last.
".
DISPLAY "12. MAINPROG terminates the entire image upon
".
DISPLAY "
execution of the STOP RUN statement.
".
STOP RUN.
IDENTIFICATION DIVISION.
*
* SUB1 is both a called and calling subprogram
*
*
It is called by MAINPROG
*
*
It then calls SUB2
PROGRAM-ID. SUB1.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
BEGIN.
DISPLAY " 3.
This is the entry point to SUB1.
".
DISPLAY " 4. SUB1 now has control.
".
DISPLAY " 5. SUB1 transfers control to SUB2.
".
CALL "SUB2"
DISPLAY " 9. SUB1 regains control
".
DISPLAY "10.
after executing the following
".
DISPLAY "
EXIT PROGRAM statement.
".
EXIT PROGRAM.
IDENTIFICATION DIVISION.
*
* SUB2 is called subprogram only
*
*
It is called by SUB1
*
PROGRAM-ID. SUB2.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
BEGIN.
DISPLAY " 6.
This is the entry point to SUB2.
".
DISPLAY " 7. SUB2 now has control.
".
DISPLAY " 8. SUB2 returns control to SUB1
".
DISPLAY "
after executing the following
".
DISPLAY "
EXIT PROGRAM statement.
".
EXIT PROGRAM.
END PROGRAM SUB2.
END PROGRAM SUB1.
END PROGRAM MAINPROG.
Example 12–5 shows the messages printed to the default output device when the
programs in Example 12–4 are run.
Interprogram Communication 12–7
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......