Integrating xHarbour code

Integrating xHarbour code

If you wish to integrate xHarbour code with Delphi application you can do so. This process include several steps.

1. Put your xHarbour code into DLL file. MedHbUDF directory contains a simple example illustrating how to turn hbudf.prg file into DLL using xHarbour and Visual C++.

2. Load your DLL file into application before using its internal functions. This can be done by using TMedConnection.LoadHarbourDll method.

3. Call the required DLL functions using TMedConnection.HbExecute method.

4. Unload your DLL file when no longer needed. Use TMedConnection.FreeHarbourDll method for this purpose.

If you wish, you may load more than one DLL file into your application.

MedHbUdf.Dll

This special DLL file is automatically loaded into application when TMedConnection object is created. It is also automatically unloaded on cleanup. If you wish MedHbUdf.Dll to be automatically loaded, it should be available in current application directory or in any directory included in system path. If MedHbUdf.dll is not found, it is not loaded but no error is raised.

Due to its automatic load/unload management and ready-to-use makefile, MedHbUdf file is a place where you can easily add xHarbour code required by your Delphi application. If your expression indexes make use of user defined functions (UDFs) this is a proposed place to put their code.

Note: If your expression indexes contain references to UDFs and their code is not availabale, an exception will be raised by Delphi application when first attempt to update table data is made.