Java Reference
In-Depth Information
The calling program can now evaluate the return parameter, in effect using the
evaluation logic of the subroutine. The calling program only needs to know how to
call the subroutine and how to evaluate the result of that call. It does not need to
know any other details of the subroutine's internal logic.
Objects behave in much the same manner. An object is a collection of code that
accepts parameters, implements a function, and returns information to the calling
program. Objects, however, differ from a standard COBOL subroutine in a num-
ber of ways. One important difference is that objects are created dynamically (at
runtime) by a program. They are always associated with, or “tied to,” the program
that created them. Furthermore, a program can create many objects of the same
type, or class.
An object can be understood as a subroutine called with a particular set of linkage
items.
MYSUB COBOL
Suppose you've defined a subroutine as follows:
IDENTIFICATION DIVISION.
PROGRAM-ID. MYSUB.
***********************************************************************
*
* 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 1.
*
* The text item will also be stored in the passed control structure in
*
* MSG-TEXT.
*
***********************************************************************
*
DATA DIVISION.
WORKING-STORAGE SECTION.
* These are the subroutine parameter definitions.
LINKAGE SECTION.
01 MYSUB-CONTROL.
03 MSG-TEXT PIC X(20).
03 MSG-SIZE PIC 9(8).
Search WWH ::




Custom Search