Mastering Oracle Power Objects Rick Greenwald and Robert Hoskin Changes in the demonstration application for use on the Macintosh platform This document describes the changes that must be made in the application code for the sample application in Mastering Oracle Power Objects from O’Reilly and Associates. The changes described below are the supplemental changes you must make to allow your application to run on a Mac platform as well as on a Windows platform. You will still have to follow the instructions listed in the book, such as creating an ORDERDAT session and creating the ORDER_ITEMS_V view, as well as making sure the logon list box has the appropriate values to connect to your own database. Database changes At the time Mastering Oracle Power Objects was published, Personal Oracle Lite had not been released for any Mac platforms. Instead, OPO was shipped with Personal Oracle. Because of this, you will not be able to use the POLite database that came with the book. The file ORDERDAT.DMP is a dump file you can load into any Oracle database, version 7.1 or later, to create the tables you will need to run the sample application. You will have to remember to make the connection string that you will use in the frmLogin form appropriate for your Oracle database. Application code changes When we were writing this book, we were undecided as to how much platform-specific information to include in our example application. One of the great virtues of Power Objects is the fact that it is a cross-platform solution - the same application can be used on Windows and Macintosh platforms. On the other hand, Version 2, in particular, includes some functionality that is only available on Windows platforms in the form of OCX controls. After the Power Objects group at Oracle informed us that 85% of the Power Objects user community were on Windows platform, we decided that we should include some explanations of Windows-only OCX controls. However, since we did not want to make our book a manual for only Windows programmers, we also decided to include the accompanying files, which accomplish virtually everything that the application in the book does without the use of OCX controls. Whenever changes have been made in the code for the applications, the previously available code has been retained, but commented out, with explanation, where it is appropriate. A detailed listing of the actual changes in each chapter follows the descriptive section. Chapter 2 changes For Windows platforms, the CloseWindow() method can be used to close a modal window. For Mac platforms, this method will not close a modal window, so the CloseWindow() method for the btnOK push button in the frmItemDetail window has been changed to a DismissModal(Self) method. Chapter 4 changes The main changes in the included applications concern the example in Chapter 4. The import and export routines use some OCXs to gather information from the user. The included application replaces all of those OCXs with native OPO classes. The common dialog OCX that gives the user the ability to select an import file has been replaced by a standard form with a data field for the pathname that is opened as a modal window. This form does not exactly replace the complete functionality of the dialog OCX, since a user can enter any pathname, rather than simply select a valid pathname, but any errors in the pathname will be trapped by the standard error handling after the OPEN statement for the import file. The rest of the changes in the code for Chapter 4 involve the replacement of the list OCX with instances of the clsPickList class, which was created in Chapter 8 and is available in the MasterLib library. One instance of the class has been used to replace some of the OCXs, while two instances acting as ‘pick list pairs’ have been used to replace the single OCX in the frmSelectColumns form. Although this involves some ‘cheating’ in the form of using a class that has not been developed in the overall flow of the book, you will (hopefully) be using classes that other people have developed in your work with Power Objects, so this is not so unusual in a real world situation. The code for the btnImport and btnExport push buttons and the push buttons in the frmLink form have been changed to use the replacement class instances instead of the original OCX controls. In the frmExportFile and frmLink forms, the CloseWindow() method called for the push button that closes the form has been changed to the DismissModal() method. Under Windows, these two methods have the same effect of closing a modal window, but on the Mac you must dismiss a window that has been opened modally. In addition to the code changes listed in detail below, you will have to create an ODBC text data source to be able to display the results of the error trapping in the frmErrors form. Creating an ODBC text data source for Mac platforms is a non-trivial task. For more information on how to properly create an ODBC data source on the Mac, we refer you to Michael Kranzdorf’s excellent OPO frequently-asked questions (FAQ) list, located on the World Wide Web at http://www.krt.com/mac/opofaq.html.. If you cannot create an ODBC text data source to display the error data and reasons, you can still use the same code to write the errant data and reason and simply use a text viewer to examine the code. Of course, one of the nice things about the error handling in this chapter is the ability to see them together in the frmErrors form. If you cannot properly use the frmErrors form, you might want to include the error and the reason in a single text file, or create a routine to read directly from the text files and display them in a different type of form. Finally, the files that are opened in the accompanying code uses a Windows-style path name. If you are successful in creating an ODBC text data source, you should write to text files that will be used by that data source and adjust the OPEN command for these files, located in the Click() method for the btnImport push button, accordingly. If you cannot, or decide not to, use an ODBC data source to review the errors, you can change the path names to anything that you would like. Chapter 8 changes The use of the spin control OCX has been replaced with a standard data field object with the same name. None of the code that references this object had to be changed. Chapter 9 changes The Crystal Reports OCX has been eliminated. Chapter 13 changes The Chapter 13 example application has not been included in these files, since the only change to the application is the addition of the PowerBrowser OCX. Listing of changes Changes in Chapter 2 - Changed entities: frmItemDetail.btnOK.Click() Changed the code for the Click() event from GetContainer().CloseWindow() to GetContainer().DismissModal(Self) Changes in Chapter 4 - Changed entities: frmSelectColumns btnExport.Click() btnImport.Click() frmExportFile.btnOK.Click() frmExportFile.btnOK.Click() frmLink frmMain New entities: dlgImport Deleted the common dialog OCX form frmMain. Created a form called “dlgImport” with a data field object called “Pathname”. Changed the call to the OCX in the Click() method for the btnImport push button on frmMain to dlgImport..OpenModal(0) to call the new dialog box instead of the OCX. And the check for no values was changed to IF ISNULL(dlgImport.Pathname.Value) THEN In addition, code to close the error files was added if there was no file selected for import. Replaced the existing frmSelectColumns from a single OCX list to a pair of pick lists - clsAvailableColumns and clsSelectedColumns. Changed the populate routine so that it calls AddItem() for the clsAvailableColumns instance. Replaced the routine to populate the array in btnExport to walk through the recordset of the second list box in frmSelectColumns. Add instance of clsPickList to replace lstColumns in frmLink with clsColumns Changed frmLink.InitializeWindow() to populate clsColumns and reference dlgImport rather than frmMain.dlgImport Modify code for btnAdd.Click() on frmLink Add instance of clsPickList called “clsLink” to replace lstLink and change code in btnAdd and btnOK to reflect the change. Changed the code for the Click() method for the btnOK and the btnCancel push button of the frmExportFile form to dismiss the modal form. Changed the code for the Click() method for the btnOK and the btnCancel push button of the frmLink form to dismiss the modal form. Changes in Chapter 8 Changed entities: frmColorQuantity frmPickColors.btnOK.Click() frmColorQuantity.btnCancel.Click() frmColorQuantity.btnOK.Click() Replaced spin control OCX spnQuantity with a data field with the same name. Changed the code for the Click() method for the btnOK push button of the frmPickColors form to dismiss the modal form. Changed the code for the Click() method for the btnOK and the btnCancel push button of the frmColorQuantity form to dismiss the modal form. Changes in Chapter 9 Changed entities: frmMain Eliminated the Crystal Reports OCX from frmMain.