Java Reference
In-Depth Information
T HE COBOL S UBROUTINE
I'll start with the COBOL subroutine. A COBOL subroutine is a source file that
contains COBOL code and implements a logical function. It is organized so that
other programs can prepare the appropriate information, call the subroutine, and
perform the function. Subroutine parameters are described in the LINKAGE SEC-
TION of the subroutine. The subroutine is able to evaluate or modify passed para-
meters as part of its algorithm.
The calling program uses a subroutine when it defines and prepares the para-
meter items for the subroutine, and then calls it. The parameters are passed to the
subroutine, using the CALL SUBROUTINE USING statement. After the subrou-
tine completes its function, the calling program can examine the parameter items
to see the information returned by the subroutine.
C ALLING A S UBROUTINE
In Figure 1.1 the calling program (CALLER) prepares a text item as a parameter. It
then calls the subroutine (MYSUB), passing this parameter and another parameter.
FIGURE 1.1
Calling a subroutine.
The subroutine accepts both of these parameters. Its algorithm is roughly de-
fined as follows: Evaluate the first parameter and set the second, based on some pre-
defined criteria. The details of the evaluation function (that is, the heart of the
subroutine's algorithm) are embedded in the subroutine.
 
Search WWH ::




Custom Search