Java Reference
In-Depth Information
*
Prepare the database message parameters, and call MYSUB.
MOVE "Unable to connect to the DataBase." TO TEXT-STRING.
CALL "MYSUB" USING MYSUB1-CONTROL, TEXT-STRING.
*
Prepare the communications message parameters, and call MYSUB.
MOVE "Invalid connection request." TO TEXT-STRING.
CALL "MYSUB" USING MYSUB2-CONTROL, TEXT-STRING.
*
Prepare the generic message parameters, and call MYSUB.
MOVE "An unknown error has occurred." TO TEXT-STRING.
CALL "MYSUB" USING MYSUB3-CONTROL, TEXT-STRING.
...
Later on in this program:
* An error has occurred. The type of error has been recorded in
* DISPLAY-MSG-TYPE-SW.
* Evaluate which type of error occurred, and display the correct
error
*
message text item.
IF DISPLAY-MSG-TYPE-SW = "D"
MOVE MSG-TEXT OF MYSUB1-CONTROL TO DISPLAY-MESSAGE
ELSE IF DISPLAY-MSG-TYPE-SW = "C"
MOVE MSG-TEXT OF MYSUB2-CONTROL TO DISPLAY-MESSAGE
ELSE
MOVE MSG-TEXT OF MYSUB3-CONTROL TO DISPLAY-MESSAGE.
PERFORM DISPLAY-ERROR-MESSAGE.
The previous code fragments are examples of how a COBOL program might
use three objects. Each of these objects is based on the class MYSUB.
T ERMS TO R EVIEW : S UBROUTINES
Here are some of the concepts that have been discussed and how to understand
them from a COBOL perspective.
Class: A subroutine is similar to a class. It can perform certain functions when
called. The subroutine developer defines these functions. Many calling pro-
grams can use this subroutine in order to perform those functions.
Interface: The signature, or parameter specification, for a particular subroutine
(or class, in OO terms). In COBOL, a subroutine's signature is the list of items
in the subroutine's LINKAGE SECTION. Some items in an interface may be
input parameters, and some may be result parameters, or both.
Search WWH ::




Custom Search