Converting to IBO Classes


Once the application is adjusted such that it makes use of IBO supported features then it is a straight forward process to convert the components from the BDE based classes to IBO based classes.

First, create a backup of the entire project at this time. You will find that until you get the hang of this process you may want to make additional preparatory changes in the source application and start the conversion from scratch again.

These are the units & classes that need to be converted:

   DBTables    to   IBODataset
   TDatabase    to    TIBODatabase
   TTable       to    TIBOTable
   TQuery       to    TIBOQuery
   TStoredProc   to    TIBOStoredProc
   TUpdateSQL   to    TIBOUpdateSQL
   TBCDField    to    TIBOBCDField
   TFloatField    to    TIBOFloatField
   TDBDataset    to    TIBODataset
   TBDEDataset    to    TIBODataset

Quick method
There is a tool called GReplace that does all of this in one shot. It examines all the PAS and DFM files and produces a report of what all needs to get changed. Then, you can optionally apply the changes that it finds and have the entire project placed in a new directory in its modified state. An entire application can be converted in just a few simple operations using this tool if all the preparations are in place.

http://www.obsof.com/public/GReplace.zip is where it can be down loaded from.

This tool stores settings into a file so that it is really easy to build a little process that does the conversion. As you work with the end result you may find other items that should be added to the search and replace list. For example, in the CSDemos sample application that comes with Delphi they have a NUMERIC( 9, 2 ) column bound to a persistent TIntegerField. This is a problem since using a TIntegerField strips off the 2 digits of precision. So, I added the following replacement entries to do the search and replace automatically:

   SalesTableTOTAL_VALUE: TIntegerField   to SalesTableTOTAL_VALUE: TIBOFloatField

This corrects a problem that otherwise would have caused a loss of precision for the column.

Tedious method
Open the DFM as text and do a search and replace of TDatabase to TIBODatabase, TTable to TIBOTable and TQuery to TIBOQuery, etc. Then, view it as a form and tell it to ignore all properties that are not found. Hit F12 and go to the code and make the same changes via search and replace. Once done CTRL+S and save the form. Then test to see if it compiles.

Be cautious of form/module dependencies. Always start out by opening the form as a *.DFM from the menu's File -> Open... command and you will not have as many hardships getting at the class declarations. Always remember that it is important to synchronize the code in the unit to any changes that are made in the DFM.

You may want to have IBO coexist with the BDE and convert it a little bit at a time, making sure that the application continues to function each step of the way. One form at a time, etc. can save oneself from getting into a tangled and lost state not knowing what is up from down.

A note about Connection Parameters

Typically in your InterBase/BDE application when you double-click on the TDatabase component you will find the Params[] property empty, or perhaps containing a user name and/or password. Under the BDE the VCL gets all of the other parameters for the connection from the idapi(32).cfg file through the AliasName property.

IBO makes the AliasName property available and, if the valid BDE alias name is entered, IBO will read the same connection params from the IDAPI file. IBO does NOT use the BDE here. It is merely making use of configuration details if they are available.

If you are working on a machine that does not have the BDE installed, you will need to enter values for three properties that are not present on the original TDatabase. These are Server, Path and Protocol. IBO provides editors for them in the Object Inspector.

In Server, enter the name of the Server, as known to your network. For a TCP/IP connection on a local machine this is will be LOCALHOST unless you have mapped the LOCALHOST IP address to a different name in the HOSTS file. It is not advisable to enter an IP address - this will cause slow and sometimes unreliable connections.
In Path, enter the absolute physical path to the database file as seen from the root of the server machine. IBO will accept the following path strings:

On Windows: D:\full_pathname\filename.gdb (where D: is a physical drive on the server machine)  
On Linux/Unix: /usr /pathname/filename.gdb (where /usr/pathname is the full and absolute path from root). Note that all file-level identifiers on Linux/Unix are case-sensitive.  
On a Netware server: /pathname/filename.gdb  

In Protocol, choose cpTCP/IP, cpNetBEUI (for Windows server only) or cpNovell (for Netware server only) if you have named a server (including LOCALHOST or equivalent). Choose cpLocal for a direct local connection.

Getting the App to Compile Again
Once the unit and class names are all replaced open the project up after deleting the *.dsk file so that you can open one form at a time. Take note of any properties that are not supported and allow them to be removed from the DFM. Examine each property mentioned and if you feel that it is a necessary property or component please contact me with your information. Also, if there are any errors or access violations you will have it narrowed down to which is the offending form. Try to do it in order of dependencies. IOW, don't open a form first that has dependencies on other forms or modules.

Once all the forms of the project have been opened and saved it is time to compile the application. Use a special "signature" and comment out everything that fails to compile and work this through until the application actually compiles. Then, start at the first item and work your way through resolving problems by doing a Find In Files for the "signature" comments you left behind.

It may be beneficial to make the changes in the source application instead of the converted application. If you need to start from scratch again you will be operating from a base that is advancing towards the end product and minimize how much you have to keep re-doing things.

Once you have worked your way through as many of the problems as you can, now is when you can actually attempt running with and testing your application at run-time.


Revised for IBO4