[fpc-pascal]Calling Procedures via pointers
Andy Powell
andy.powell at vocalisinternet.com
Wed Oct 29 16:02:51 CET 2003
Hi,
I've been away from Pascal for about 10 years now and have just started to
get back into it. So, spank me hard and call me a newbie if you must...
Anyhow, onto the problem...
I'm designing a unit (and a little test application) that i want to add a
call back function to (as exit code)... i.e.
The program gives the unit a pointer to the procedure MyCallback
When an error occurs when the unit is communicating to the device (for
example a serial device) if the pointer pCallback is not NIL I'd like to be
able to call the user defined procedure, in this case MyCallBack.
The idea is that I can compile the unit, then define the exit code in my
individual applications... can someone give me some pointers (pun intended)
on how to go about it....
Many thanks
Andy
below is the sort of thing i'm trying to do...
in program:
Procedure MyCallback();
Begin
{do some stuff then}
Halt;
End;
in unit:
Procedure SetCallBack(pProc : Pointer);
Begin
pCallBack := pProc;
End;
{ Carry out the procedure the user defined}
Procedure DoCallBack;
Begin
If (pCallBack<>NIL) then
{Call the users procedure}
else
Halt;
End;
More information about the fpc-pascal
mailing list