Java Reference
In-Depth Information
In the example so far, MYSUB can only support one message type (i.e., evalu-
ate TEXT-STRING). Suppose you want MYSUB to support multiple functions that
are in some way related. You can do this by extending the MYSUB-CONTROL to
include an ACTION-SWITCH. This item is used by the calling program to specify
the function requested.
MYSUB COBOL
MYSUB is extended to add an action switch to its interface.
IDENTIFICATION DIVISION.
PROGRAM-ID. MYSUB.
DATA DIVISION.
WORKING-STORAGE SECTION.
************************************************************************
* This routine accepts a text item as a parameter and evaluates the *
* text. If the text is all spaces, MSG-SIZE will be set to 0. Else, *
* MSG-SIZE will be set to *
* Only if requested, the text item will also be stored *
* in the passed control structure. *
************************************************************************
LINKAGE 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 USING MYSUB-CONTROL, TEXT-STRING.
MYSUB-INITIAL SECTION.
MYSUB-INITIAL-S.
*
Perform the subroutine's function.
IF TEXT-STRING = SPACES
MOVE 0 TO MSG-SIZE
ELSE
MOVE 1 TO MSG-SIZE.
*
Evaluate if this additional function was requested.
*
If yes, perform it (i.e., save the string in TEXT-STRING).
Search WWH ::




Custom Search