This is a readme file for the TPCallback DLL by TiePie engineering.


Information:

The DLL can be used in situations where a callback routine needs to be used in
a framework that does not support callbacks, but does support COM events. An 
example of such a framework is Matlab.

Matlab does not support handing a pointer to a callback routine. According to
the Mathworks website, there is no way to work with callback routines in Matlab:
"The ability to use shared library functions that have function pointer inputs
is not available in MATLAB. There is no way to write a MATLAB function that is
compatible with a C function pointer."
( http://www.mathworks.com/support/solutions/data/1-6C8PEQ.html?solution=1-6C8PEQ ).

The solution provided in the DLL is to create a COM object that serves as a
converter from callback to COM event. This is a good solution because Matlab
can respond to COM events by executing a script.


Installation:

This file should have come with a file called TPCallback.dll. You can copy that
file anywhere you like and register it in Windows by executing TPCallback_Register.bat
in it's folder. This will register the COM object 'TPCallback.TiePieCallbackAdapter'.


Useage:

1. Create a 'TPCallback.TiePieCallbackAdapter' object.
  (Matlab: hCallBackAdapter = actxserver('TPCallback.TiePieCallbackAdapter');)

2. Tie an event handler to the object's event.
  (Matlab: hCallBackAdapter.registerevent( {'OnCallbackCalled' 'CallbackScript'} );)

3. Supply the pointer to the callback routine to code that can call it, such as a DLL.
  (Matlab: calllib('DLL' , 'SetDataReadyCallback', hCallBackAdapter.CallbackPointer);)

The COM event OnCallbackCalled will now be fired every time the callback routine of the adapter object is called.