Java Reference
In-Depth Information
CALLER COBOL
Now, CALLER can pass one or two parameters.
IDENTIFICATION DIVISION.
PROGRAM-ID. CALLER.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 MYSUB-CONTROL.
03 MYSUB-ACTION-SWITCH PIC X.
88 MYSUB-ACTION-EVALUATE VALUE "E".
88 MYSUB-ACTION-SET-AND-EVALUATE VALUE "S".
03 MSG-TEXT PIC X(20).
03 MSG-SIZE PIC 9(8).
01 TEXT-STRING PIC X(20).
...
PROCEDURE DIVISION.
START-PROGRAM SECTION.
START-PROGRAM-S.
* Set ACTION-SWITCH to the function required (set and evaluate).
MOVE "S" TO MYSUB-ACTION-SWITCH.
* Clear the two MYSUB control items, to make sure you see the result.
MOVE SPACES TO MYSUB-TEXT.
MOVE ZEROS TO MYSUB-SIZE.
* Call MYSUB with two parameters.
MOVE "ANYTEXT" TO TEXT-STRING.
CALL "MYSUB" USING MYSUB-CONTROL, TEXT-STRING.
DISPLAY "MSG-TEXT: ", MSG-TEXT,
" MSG-SIZE: ", MSG-SIZE.
* Set ACTION-SWITCH to the function required (evaluate only).
MOVE "E" TO MYSUB-ACTION-SWITCH.
* Clear the two MYSUB control items, so you are sure to see the *
* result.
MOVE SPACES TO MYSUB-TEXT.
MOVE ZEROS TO MYSUB-SIZE.
* Call MYSUB, passing only one parameter.
* The stored string in MSG-TEXT will be evaluated.
CALL "MYSUB" USING MYSUB-CONTROL.
DISPLAY "MSG-TEXT: ", MSG-TEXT,
" MSG-SIZE: ", MSG-SIZE.
*
Try it with some text in MSG-TEXT.
MOVE "Some Text" TO MYSUB-TEXT.
Search WWH ::




Custom Search