(C) Copyright IBM Corp. 1996 All Rights Reserved. IBM is a registered trademark of the International Business Machines Corporation U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. IBM VisualAge COBOL/C++ Direct-to-SOM Object-Oriented Sample Programs Introduction Object technology on OS/2 includes support for IBM VisualAge C++ and IBM VisualAge for COBOL to generate System Object Model (SOM) objects directly from source code. One of the benefits of using direct-to-SOM is programming language neutrality along with the object-oriented characteristics of encapsulation, inheritance, and polymorphism. Examples of this language neutrality found in these sample programs are: - A COBOL client using C++ classes - A COBOL subclass inheriting from a C++ class, overriding an existing method and adding a new method - A COBOL client using the COBOL subclass and C++ classes - A C++ client using the COBOL subclass and C++ classes. Caveat These programs have not been exhaustively tested on all system configurations. The system on which the programs were developed is a PS/2 486 processor with 32 meg. of RAM running OS/2 2.11, VisualAge C++ 3.0, and VisualAge for COBOL with CSD1. At present, these programs are non-GUI. The authors hopes to have time to create a GUI version in the very near future. License IBM grants the right to use, reproduce, and distribute this software provided that (1) it is not distributed for profit, (2) it is used only with licensed copies of OS/2, VisualAge C++, and VisualAge for COBOL, (3) all copyright notices remain with the software, (5) the end user agrees to the license. This software is provided in "as is" condition without warranty of any kind and no support will be provided. This software is NOT supported by either IBM technical support channels or the IBM VisualAge for COBOL for OS/2 CompuServ forum. IBM and its vendors take no responsibility and are not liable for any consequences or damages of any kind resulting from the use or existence of this software. IBM does not guarantee that the software will run on all machines. IBM is not obligated to provide any updates to this software. The Three Scenarios The programs are a phone book in which you can search for a name, add a name, delete a name, go to the previous name, or go to the next name. In scenarios two and three, you can also display the entire phone book. Scenario One: A COBOL client program uses C++ classes. Source Files: MAIN1.CMD - command file COBMAIN1.CBL - client source COBMAIN1.DEF - client module definition file MYSTRING.HH - header file for string class MYSTRING.CPP - implementation file for string class MYSTRING.DEF - module definition file for string class PENTRY.HH - header file for phone entry class PENTRY.CPP - implementation file for phone entry class PENTRY.DEF - module definition file for phone entry class PBOOK.HH - header file for phone book class PBOOK.CPP - implementation file for phone book class PBOOK.DEF - module definition file for phone book class OOILC.DATA - data file (contains cartoon characters) Scenario Two: A COBOL client program uses a COBOL subclass that inherits from a C++ class. The COBOL subclass overrides one method and adds a new method. Source Files: MAIN2.CMD - command file COBMAIN2.CBL - client source COBMAIN2.DEF - client module definition file COBPHONE.CBL - subclass source COBPHONE.DEF - subclass module definition file MYSTRING.HH - header file for string class MYSTRING.CPP - implementation file for string class MYSTRING.DEF - module definition file for string class PENTRY.HH - header file for phone entry class PENTRY.CPP - implementation file for phone entry class PENTRY.DEF - module definition file for phone entry class PBOOK.HH - header file for phone book class PBOOK.CPP - implementation file for phone book class PBOOK.DEF - module definition file for phone book class OOILC.DATA - data file Scenario Three: A C++ client program uses a COBOL subclass that inherits from a C++ class. Source Files: MAIN3.CMD - command file CPPMAIN3.CPP - client source CPPMAIN3.DEF - client module definition file COBPHONE.CBL - subclass source COBPHONE.DEF - subclass module definition file COBPHONE.HH - header file of subclass required for client program MYSTRING.HH - header file for string class MYSTRING.CPP - implementation file for string class MYSTRING.DEF - module definition file for string class PENTRY.HH - header file for phone entry class PENTRY.CPP - implementation file for phone entry class PENTRY.DEF - module definition file for phone entry class PBOOK.HH - header file for phone book class PBOOK.CPP - implementation file for phone book class PBOOK.DEF - module definition file for phone book class OOILC.DATA - data file Running The Scenarios 1) Unzip, using PKUNZIP2, the package, VADTSILC ZIPBIN, into a subdirectory. 2) To run scenario one, type MAIN1. To run scenario two, type MAIN2. To run scenario three, type MAIN3. 3) Enjoy and learn! E. S. (Beth) Flint (ESFLINT@VNET.IBM.COM)